From f8f4fff962a346c2d29ebf8e3ef4be3d3fd1fce0 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Wed, 30 Nov 2005 06:53:06 +0000 Subject: [PATCH] * coff-objfmt.c (coff_objfmt_output_secthead): Use sprintf instead of snprintf when outputting /nnn section names; snprintf doesn't port well to mingw at least. This also generates more correct output (fills with 0s). svn path=/trunk/yasm/; revision=1322 --- modules/objfmts/coff/coff-objfmt.c | 5 +++-- modules/objfmts/win32/tests/win32-longsect.hex | 14 +++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/modules/objfmts/coff/coff-objfmt.c b/modules/objfmts/coff/coff-objfmt.c index 792e2fc3..aa335fdb 100644 --- a/modules/objfmts/coff/coff-objfmt.c +++ b/modules/objfmts/coff/coff-objfmt.c @@ -719,8 +719,9 @@ coff_objfmt_output_secthead(yasm_section *sect, /*@null@*/ void *d) /* section name */ localbuf = info->buf; if (strlen(yasm_section_get_name(sect)) > 8) { - /* 9 because snprintf always forces a terminating NUL */ - snprintf((char *)localbuf, 9, "/%ld", csd->strtab_name); + char namenum[30]; + sprintf(namenum, "/%ld", csd->strtab_name); + strncpy((char *)localbuf, namenum, 8); } else strncpy((char *)localbuf, yasm_section_get_name(sect), 8); localbuf += 8; diff --git a/modules/objfmts/win32/tests/win32-longsect.hex b/modules/objfmts/win32/tests/win32-longsect.hex index dbac4fcd..25d4812e 100644 --- a/modules/objfmts/win32/tests/win32-longsect.hex +++ b/modules/objfmts/win32/tests/win32-longsect.hex @@ -61,8 +61,8 @@ 2f 34 00 -78 -74 +00 +00 00 00 00 @@ -102,7 +102,7 @@ 33 37 00 -74 +00 00 00 00 @@ -182,10 +182,10 @@ 35 38 00 -74 -6c -79 -38 +00 +00 +00 +00 0c 00 00 -- 2.40.0