tlib9, libndb: exclude terminating null from strncpy bound - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit e6ed10f25e4b2ea791d8e52253f7d806316420e9
 (DIR) parent 540caa5873bcc3bc2a0e1896119f5b53a0e8e630
 (HTM) Author: Neven Sajko <nsajko@gmail.com>
       Date:   Mon,  6 Jan 2020 22:57:05 +0000
       
       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
       
       Diffstat:
         M src/lib9/ctime.c                    |       2 +-
         M src/libndb/sysdnsquery.c            |       2 +-
       
       2 files changed, 2 insertions(+), 2 deletions(-)
       ---
 (DIR) diff --git a/src/lib9/ctime.c b/src/lib9/ctime.c
       t@@ -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;
 (DIR) diff --git a/src/libndb/sysdnsquery.c b/src/libndb/sysdnsquery.c
       t@@ -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;
        }