commit e6ed10f25e4b2ea791d8e52253f7d806316420e9 from: Neven Sajko via: Dan Cross date: Tue Jan 07 21:23:40 2020 UTC lib9, libndb: exclude terminating null from strncpy bound GCC pointed this out with some "warning: ‘strncpy’ specified bound NUM equals destination size [-Wstringop-truncation]" warnings. Change-Id: Id8408b165f6e4ae82c96a77599d89f658d979b32 commit - 540caa5873bcc3bc2a0e1896119f5b53a0e8e630 commit + e6ed10f25e4b2ea791d8e52253f7d806316420e9 blob - a9ce7b7a7181bc5de84e579aac083cf66607456f blob + 9fcd6200886310d43c3822dc6600626b894b2d9d --- src/lib9/ctime.c +++ src/lib9/ctime.c @@ -58,7 +58,7 @@ localtime(long tim) if (zonelookuptinfo(&ti, tim)!=-1) { ct = gmtime(tim+ti.tzoff); - strncpy(ct->zone, ti.zone, sizeof ct->zone); + strncpy(ct->zone, ti.zone, sizeof ct->zone - 1); ct->zone[sizeof ct->zone-1] = 0; ct->tzoff = ti.tzoff; return ct; blob - b9661be1c22845ce90336351a1e597afc6a674ea blob + 0a771e2b9f0158c91f542985f300ff0ef123d56e --- src/libndb/sysdnsquery.c +++ src/libndb/sysdnsquery.c @@ -84,7 +84,7 @@ mkptrname(char *ip, char *rip, int rlen) static void nstrcpy(char *to, char *from, int len) { - strncpy(to, from, len); + strncpy(to, from, len-1); to[len-1] = 0; }