diff options
author | Neven Sajko <nsajko@gmail.com> | 2020-01-06 22:57:05 +0000 |
---|---|---|
committer | Dan Cross <crossd@gmail.com> | 2020-01-07 16:23:40 -0500 |
commit | e6ed10f25e4b2ea791d8e52253f7d806316420e9 (patch) | |
tree | 56951dd1bf82dc08bceed1abd00447b545cb9a08 | |
parent | 540caa5873bcc3bc2a0e1896119f5b53a0e8e630 (diff) | |
download | plan9port-e6ed10f25e4b2ea791d8e52253f7d806316420e9.tar.gz plan9port-e6ed10f25e4b2ea791d8e52253f7d806316420e9.tar.bz2 plan9port-e6ed10f25e4b2ea791d8e52253f7d806316420e9.zip |
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
-rw-r--r-- | src/lib9/ctime.c | 2 | ||||
-rw-r--r-- | src/libndb/sysdnsquery.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/lib9/ctime.c b/src/lib9/ctime.c index a9ce7b7a..9fcd6200 100644 --- a/src/lib9/ctime.c +++ b/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; diff --git a/src/libndb/sysdnsquery.c b/src/libndb/sysdnsquery.c index b9661be1..0a771e2b 100644 --- a/src/libndb/sysdnsquery.c +++ b/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; } |