Excluding winedump for now, since it has a lot of tricky sprintf calls to replace
From: Brendan Shanks bshanks@codeweavers.com
--- tools/sfnt2fon/sfnt2fon.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/tools/sfnt2fon/sfnt2fon.c b/tools/sfnt2fon/sfnt2fon.c index 2c307dcce8a..bf31124aa25 100644 --- a/tools/sfnt2fon/sfnt2fon.c +++ b/tools/sfnt2fon/sfnt2fon.c @@ -881,12 +881,15 @@ int main(int argc, char **argv) name = get_face_name( info[i] ); fontdir_len += 0x74 + strlen(name) + 1; if(i == 0) { - sprintf(non_resident_name, "FONTRES 100,%d,%d : %s %d", - info[i]->hdr.fi.dfVertRes, info[i]->hdr.fi.dfHorizRes, - name, info[i]->hdr.fi.dfPoints ); + snprintf(non_resident_name, sizeof(non_resident_name), + "FONTRES 100,%d,%d : %s %d", + info[i]->hdr.fi.dfVertRes, info[i]->hdr.fi.dfHorizRes, + name, info[i]->hdr.fi.dfPoints ); strcpy(resident_name, name); } else { - sprintf(non_resident_name + strlen(non_resident_name), ",%d", info[i]->hdr.fi.dfPoints ); + snprintf(non_resident_name + strlen(non_resident_name), + sizeof(non_resident_name) - strlen(non_resident_name), + ",%d", info[i]->hdr.fi.dfPoints ); } }
From: Brendan Shanks bshanks@codeweavers.com
--- tools/widl/header.c | 10 +++++----- tools/widl/register.c | 11 ++++++----- tools/widl/typegen.c | 4 ++-- tools/widl/widl.c | 2 +- tools/widl/write_msft.c | 4 ++-- tools/widl/write_sltg.c | 6 +++--- 6 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/tools/widl/header.c b/tools/widl/header.c index f0fa1b28b73..27ef8b5c288 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -109,7 +109,7 @@ static const char *uuid_string(const struct uuid *uuid) { static char buf[37];
- sprintf(buf, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + snprintf(buf, sizeof(buf), "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", uuid->Data1, uuid->Data2, uuid->Data3, uuid->Data4[0], uuid->Data4[1], uuid->Data4[2], uuid->Data4[3], uuid->Data4[4], uuid->Data4[5], uuid->Data4[6], uuid->Data4[7]);
@@ -199,7 +199,7 @@ static void write_fields(FILE *h, var_list_t *fields, enum name_type name_type) if(nameless_struct_cnt == 1) { name = "__C89_NAMELESSSTRUCTNAME"; }else if(nameless_struct_i < 5 /* # of supporting macros */) { - sprintf(buf, "__C89_NAMELESSSTRUCTNAME%d", ++nameless_struct_i); + snprintf(buf, sizeof(buf), "__C89_NAMELESSSTRUCTNAME%d", ++nameless_struct_i); name = buf; } } @@ -210,7 +210,7 @@ static void write_fields(FILE *h, var_list_t *fields, enum name_type name_type) if(nameless_union_cnt == 1) { name = "__C89_NAMELESSUNIONNAME"; }else if(nameless_union_i < 8 /* # of supporting macros */ ) { - sprintf(buf, "__C89_NAMELESSUNIONNAME%d", ++nameless_union_i); + snprintf(buf, sizeof(buf), "__C89_NAMELESSUNIONNAME%d", ++nameless_union_i); name = buf; } } @@ -1049,9 +1049,9 @@ static char *get_vtbl_entry_name(const type_t *iface, const var_t *func) { static char buff[255]; if (is_inherited_method(iface, func)) - sprintf(buff, "%s_%s", iface->name, get_name(func)); + snprintf(buff, sizeof(buff), "%s_%s", iface->name, get_name(func)); else - sprintf(buff, "%s", get_name(func)); + snprintf(buff, sizeof(buff), "%s", get_name(func)); return buff; }
diff --git a/tools/widl/register.c b/tools/widl/register.c index 02861f3f1d0..c5600c9e7ea 100644 --- a/tools/widl/register.c +++ b/tools/widl/register.c @@ -37,10 +37,11 @@ static int indent; static const char *format_uuid( const struct uuid *uuid ) { static char buffer[40]; - sprintf( buffer, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}", - uuid->Data1, uuid->Data2, uuid->Data3, - uuid->Data4[0], uuid->Data4[1], uuid->Data4[2], uuid->Data4[3], - uuid->Data4[4], uuid->Data4[5], uuid->Data4[6], uuid->Data4[7] ); + snprintf( buffer, sizeof(buffer), + "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}", + uuid->Data1, uuid->Data2, uuid->Data3, + uuid->Data4[0], uuid->Data4[1], uuid->Data4[2], uuid->Data4[3], + uuid->Data4[4], uuid->Data4[5], uuid->Data4[6], uuid->Data4[7] ); return buffer; }
@@ -358,7 +359,7 @@ void output_typelib_regscript( const typelib_t *typelib ) expr = get_attrp( typelib->attrs, ATTR_ID ); if (expr) { - sprintf(id_part, "\%d", expr->cval); + snprintf(id_part, sizeof(id_part), "\%d", expr->cval); resname = strmake("%s\%d", typelib_name, expr->cval); } put_str( indent, "'%x' { %s = s '%%MODULE%%%s' }\n", diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c index 921bdd870c6..c29bbba1c1c 100644 --- a/tools/widl/typegen.c +++ b/tools/widl/typegen.c @@ -1270,7 +1270,7 @@ static unsigned int write_new_procformatstring_type(FILE *file, int indent, cons if (flags & IsBasetype) strcat( buffer, " base type," ); if (flags & IsByValue) strcat( buffer, " by value," ); if (flags & IsSimpleRef) strcat( buffer, " simple ref," ); - if (flags >> 13) sprintf( buffer + strlen(buffer), " srv size=%u,", (flags >> 13) * 8 ); + if (flags >> 13) snprintf( buffer + strlen(buffer), sizeof(buffer) - strlen(buffer), " srv size=%u,", (flags >> 13) * 8 ); strcpy( buffer + strlen( buffer ) - 1, " */" ); print_file( file, indent, "NdrFcShort(0x%hx),\t%s\n", flags, buffer ); print_file( file, indent, "NdrFcShort(0x%x), /* stack offset = %u */\n", @@ -4896,7 +4896,7 @@ void declare_stub_args( FILE *file, int indent, const var_t *func ) type_to_print = &var->declspec; else type_to_print = type_pointer_get_ref(var->declspec.type); - sprintf(name, "_W%u", i++); + snprintf(name, sizeof(name), "_W%u", i++); write_type_decl(file, type_to_print, name); fprintf(file, ";\n"); } diff --git a/tools/widl/widl.c b/tools/widl/widl.c index 6eb81d12860..e92f9a85497 100644 --- a/tools/widl/widl.c +++ b/tools/widl/widl.c @@ -243,7 +243,7 @@ static void add_widl_version_define(void) if (p) version += atoi(p + 1);
- sprintf(version_str, "__WIDL__=0x%x", version); + snprintf(version_str, sizeof(version_str), "__WIDL__=0x%x", version); wpp_add_cmdline_define(version_str); }
diff --git a/tools/widl/write_msft.c b/tools/widl/write_msft.c index 66401fd09ed..b0401d81238 100644 --- a/tools/widl/write_msft.c +++ b/tools/widl/write_msft.c @@ -2741,7 +2741,7 @@ static void save_all_changes(msft_typelib_t *typelib)
expr_t *expr = get_attrp( typelib->typelib->attrs, ATTR_ID ); if (expr) - sprintf( typelib_id, "#%d", expr->cval ); + snprintf( typelib_id, sizeof(typelib_id), "#%d", expr->cval ); add_output_to_resources( "TYPELIB", typelib_id ); if (strendswith( typelib_name, "_t.res" )) /* add typelib registration */ output_typelib_regscript( typelib->typelib ); @@ -2817,7 +2817,7 @@ int create_msft_typelib(typelib_t *typelib) * - a string representation of those */ cur_time = 2147483647; - sprintf(info_string, "Created by WIDL version %s at %s", PACKAGE_VERSION, asctime(gmtime(&cur_time))); + snprintf(info_string, sizeof(info_string), "Created by WIDL version %s at %s", PACKAGE_VERSION, asctime(gmtime(&cur_time))); set_custdata(msft, &midl_info_guid, VT_BSTR, info_string, &msft->typelib_header.CustomDataOffset); set_custdata(msft, &midl_time_guid, VT_UI4, &cur_time, &msft->typelib_header.CustomDataOffset); set_custdata(msft, &midl_version_guid, VT_UI4, &version, &msft->typelib_header.CustomDataOffset); diff --git a/tools/widl/write_sltg.c b/tools/widl/write_sltg.c index 497cfb98d11..414a8ec6855 100644 --- a/tools/widl/write_sltg.c +++ b/tools/widl/write_sltg.c @@ -544,7 +544,7 @@ static void init_typeinfo(struct sltg_typeinfo_header *ti, const type_t *type, s
for (i = 0; i < hrefmap->href_count; i++) { - sprintf(name, "*\Rffff*#%x", hrefmap->href[i]); + snprintf(name, sizeof(name), "*\Rffff*#%x", hrefmap->href[i]); hrefinfo_size += 8 + 2 + strlen(name); }
@@ -581,7 +581,7 @@ static void write_hrefmap(struct sltg_data *data, const struct sltg_hrefmap *hre { short len;
- sprintf(name, "*\Rffff*#%x", hrefmap->href[i]); + snprintf(name, sizeof(name), "*\Rffff*#%x", hrefmap->href[i]); len = strlen(name);
append_data(data, &len, sizeof(len)); @@ -1733,7 +1733,7 @@ static void save_all_changes(struct sltg_typelib *typelib)
expr_t *expr = get_attrp(typelib->typelib->attrs, ATTR_ID); if (expr) - sprintf(typelib_id, "#%d", expr->cval); + snprintf(typelib_id, sizeof(typelib_id), "#%d", expr->cval); add_output_to_resources("TYPELIB", typelib_id); if (strendswith(typelib_name, "_t.res")) /* add typelib registration */ output_typelib_regscript(typelib->typelib);
From: Brendan Shanks bshanks@codeweavers.com
--- tools/winebuild/import.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c index 1ca2048284b..bbf722633ae 100644 --- a/tools/winebuild/import.c +++ b/tools/winebuild/import.c @@ -217,7 +217,8 @@ static char *encode_dll_name( const char *name ) ret = p = xmalloc( len * 4 + 1 ); for ( ; len > 0; len--, name++) { - if (!strchr( valid_chars, *name )) p += sprintf( p, "$x%02x", *name ); + if (!strchr( valid_chars, *name )) + p += snprintf( p, (len * 4 + 1) - (p - ret), "$x%02x", *name ); else *p++ = *name; } *p = 0;
From: Brendan Shanks bshanks@codeweavers.com
--- tools/wmc/write.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/wmc/write.c b/tools/wmc/write.c index 353a503f674..ec660a95c12 100644 --- a/tools/wmc/write.c +++ b/tools/wmc/write.c @@ -336,7 +336,7 @@ static char *make_string(WCHAR *uc, int len) } else { - int n = sprintf(cptr, "\x%04x", *uc); + int n = snprintf(cptr, (7*len + 12) - (cptr - str), "\x%04x", *uc); cptr += n; b += n; }
From: Brendan Shanks bshanks@codeweavers.com
--- tools/wrc/ppl.l | 4 ++-- tools/wrc/wrc.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/tools/wrc/ppl.l b/tools/wrc/ppl.l index 4748d735fa2..947b344e033 100644 --- a/tools/wrc/ppl.l +++ b/tools/wrc/ppl.l @@ -907,12 +907,12 @@ static void expand_special(pp_entry_t *ppp) if(!strcmp(ppp->ident, "__LINE__")) { buf = xrealloc(buf, 32); - sprintf(buf, "%d", pp_status.line_number); + snprintf(buf, 32, "%d", pp_status.line_number); } else if(!strcmp(ppp->ident, "__FILE__")) { buf = xrealloc(buf, strlen(pp_status.input) + 3); - sprintf(buf, ""%s"", pp_status.input); + snprintf(buf, strlen(pp_status.input) + 3, ""%s"", pp_status.input); }
if(pp_flex_debug) diff --git a/tools/wrc/wrc.c b/tools/wrc/wrc.c index 36f439ff88e..15b63509f74 100644 --- a/tools/wrc/wrc.c +++ b/tools/wrc/wrc.c @@ -209,11 +209,11 @@ static void set_version_defines(void) major = NULL; patchlevel = version; } - sprintf( buffer, "__WRC__=%s", major ? major : "0" ); + snprintf( buffer, sizeof(buffer), "__WRC__=%s", major ? major : "0" ); wpp_add_cmdline_define(buffer); - sprintf( buffer, "__WRC_MINOR__=%s", minor ? minor : "0" ); + snprintf( buffer, sizeof(buffer), "__WRC_MINOR__=%s", minor ? minor : "0" ); wpp_add_cmdline_define(buffer); - sprintf( buffer, "__WRC_PATCHLEVEL__=%s", patchlevel ? patchlevel : "0" ); + snprintf( buffer, sizeof(buffer), "__WRC_PATCHLEVEL__=%s", patchlevel ? patchlevel : "0" ); wpp_add_cmdline_define(buffer); free( version ); }
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=148487
Your paranoid android.
=== debian11b (64 bit WoW report) ===
Report validation errors: mshtml:script crashed (c0000005)
Rémi Bernon (@rbernon) commented about tools/winebuild/import.c:
ret = p = xmalloc( len * 4 + 1 ); for ( ; len > 0; len--, name++) {
if (!strchr( valid_chars, *name )) p += sprintf( p, "$x%02x", *name );
if (!strchr( valid_chars, *name ))
p += snprintf( p, (len * 4 + 1) - (p - ret), "$x%02x", *name );
This one look a bit awful, what about keeping an end pointer, initialized right after the alloc instead?
Rémi Bernon (@rbernon) commented about tools/wmc/write.c:
} else {
int n = sprintf(cptr, "\\x%04x", *uc);
int n = snprintf(cptr, (7*len + 12) - (cptr - str), "\\x%04x", *uc);
Same here.