Remove a few more instances of strncpy.
diff --git a/tools/sfnt2fnt.c b/tools/sfnt2fnt.c index d3d9124..8387421 100644 --- a/tools/sfnt2fnt.c +++ b/tools/sfnt2fnt.c
@@ -163,7 +163,6 @@ int num_names; const union cptable *cptable; FT_SfntName sfntname; - char namebuf[4096]; TT_OS2 *os2; cptable = wine_cp_get_table(enc); if(!cptable) { @@ -207,13 +206,12 @@ num_names = FT_Get_Sfnt_Name_Count(face); for(i = 0; i <num_names; i++) { FT_Get_Sfnt_Name(face, i, &sfntname); - memcpy(namebuf, sfntname.string, sfntname.string_len); - namebuf[sfntname.string_len] = '\0'; if(sfntname.platform_id == 1 && sfntname.encoding_id == 0 && sfntname.language_id == 0 && sfntname.name_id == 0) { - strncpy(hdr.dfCopyright, namebuf, 60); - hdr.dfCopyright[59] = '\0'; - } + size_t len = min( sfntname.string_len, sizeof(hdr.dfCopyright)-1 ); + memcpy(hdr.dfCopyright, sfntname.string, len); + hdr.dfCopyright[len] = 0; + } } os2 = FT_Get_Sfnt_Table(face, ft_sfnt_os2);
diff --git a/tools/winedump/dump.c b/tools/winedump/dump.c index 4a269ab..b594753 100644 --- a/tools/winedump/dump.c +++ b/tools/winedump/dump.c
@@ -86,15 +86,16 @@ const char* get_time_str(DWORD _t) { time_t t = (time_t)_t; + const char *str = ctime(&t); + size_t len = strlen(str); static char buf[128]; - /* FIXME: I don't get the same values from MS' pedump running under Wine... * I wonder if Wine isn't broken wrt to GMT settings... */ - strncpy(buf, ctime(&t), sizeof(buf)); - buf[sizeof(buf) - 1] = '\0'; - if (buf[strlen(buf)-1] == '\n') - buf[strlen(buf)-1] = '\0'; + if (len && str[len-1] == '\n') len--; + if (len >= sizeof(buf)) len = sizeof(buf) - 1; + memcpy( buf, str, len ); + buf[len] = 0; return buf; }