Introduced flag bit1 with Text_shellsafe() for double sized target string

This commit is contained in:
Thomas Schmitt 2011-05-06 12:05:39 +00:00
parent f2fc3957ce
commit 65df49006f
2 changed files with 8 additions and 5 deletions

View File

@ -1013,19 +1013,22 @@ ex:;
/* @param flag bit0= append to out_text rather than overwrite it
bit1= length limit is 10 * SfileadrL rather than 5 *
*/
char *Text_shellsafe(char *in_text, char *out_text, int flag)
{
int l,i,ol= 0,w=0;
int l,i,w=0, limit= 5 * SfileadrL;
if(flag&1)
ol= w= strlen(out_text);
w= strlen(out_text);
if(flag & 2)
limit= 10 * SfileadrL;
/* enclose everything by hard quotes */
l= strlen(in_text);
out_text[w++]= '\'';
for(i=0;i<l;i++){
if(in_text[i]=='\''){
if(w+7>5*SfileadrL+ol)
if(w + 7 > limit)
goto overflow;
/* escape hard quote within the text */
out_text[w++]= '\'';
@ -1034,7 +1037,7 @@ char *Text_shellsafe(char *in_text, char *out_text, int flag)
out_text[w++]= '"';
out_text[w++]= '\'';
} else {
if(w+3>5*SfileadrL) {
if(w + 3 > limit) {
overflow:;
strncpy(out_text, "'xorriso: TEXT MUCH TOO LONG ... ",33);
break;

View File

@ -1 +1 @@
#define Xorriso_timestamP "2011.05.05.163926"
#define Xorriso_timestamP "2011.05.06.120600"