X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tools%2Fcvt_data.c;h=09e7ebc54d7b688899cb86c00ff7847c6b5d7e32;hb=206c0727041648e9545d16b25e591880f2c58f79;hp=93c5fd00d46671116c1e03180916c46cabbb507c;hpb=c8fb3694c071ffe819509e01292b2a1520a70017;p=ia32rtools.git diff --git a/tools/cvt_data.c b/tools/cvt_data.c index 93c5fd0..09e7ebc 100644 --- a/tools/cvt_data.c +++ b/tools/cvt_data.c @@ -195,7 +195,7 @@ static char *escape_string(char *s) for (; *s != 0; s++) { if (*s == '"') { - strcpy(t, "\\x22"); + strcpy(t, "\\\""); t += strlen(t); continue; } @@ -206,7 +206,9 @@ static char *escape_string(char *s) } *t++ = *s; } - *t = *s; + *t++ = *s; + if (t - buf > sizeof(buf)) + aerr("string is too long\n"); return strcpy(s, buf); } @@ -691,7 +693,9 @@ int main(int argc, char *argv[]) val = parse_number(words[w]); if (val & ~0xff) aerr("bad string trailing byte?\n"); - fprintf(fout, "\\x%02lx", val); + // unfortunately \xHH is unusable - gas interprets + // things like \x27b as 0x7b, so have to use octal here + fprintf(fout, "\\%03lo", val); } } fprintf(fout, "\"");