INN commit: branches/2.6 (6 files)

INN Commit rra at isc.org
Thu May 30 14:18:49 UTC 2019


    Date: Thursday, May 30, 2019 @ 07:18:48
  Author: iulius
Revision: 10342

Fix string operation warnings with GCC 9

Also use CNFSNASIZ when appropriate (for buffer names).

Modified:
  branches/2.6/backends/archive.c
  branches/2.6/nnrpd/commands.c
  branches/2.6/nnrpd/tls.c
  branches/2.6/storage/buffindexed/buffindexed.c
  branches/2.6/storage/cnfs/cnfs.c
  branches/2.6/storage/timecaf/caf.c

-----------------------------------+
 backends/archive.c                |    2 +-
 nnrpd/commands.c                  |    4 +++-
 nnrpd/tls.c                       |    5 +++--
 storage/buffindexed/buffindexed.c |    9 ++++++++-
 storage/cnfs/cnfs.c               |   23 +++++++++++++++++++----
 storage/timecaf/caf.c             |    2 +-
 6 files changed, 35 insertions(+), 10 deletions(-)

Modified: backends/archive.c
===================================================================
--- backends/archive.c	2019-05-30 14:16:50 UTC (rev 10341)
+++ backends/archive.c	2019-05-30 14:18:48 UTC (rev 10342)
@@ -462,7 +462,7 @@
 
     /* Write the rest of stdin to the spool file. */
     status = 0;
-    if (fprintf(spool, "%s\n", line) == EOF) {
+    if (fprintf(spool, "%s\n", line != NULL ? line : "") == EOF) {
         syswarn("cannot start spool");
         status = 1;
     }

Modified: nnrpd/commands.c
===================================================================
--- nnrpd/commands.c	2019-05-30 14:16:50 UTC (rev 10341)
+++ nnrpd/commands.c	2019-05-30 14:18:48 UTC (rev 10342)
@@ -241,7 +241,9 @@
     PERMaccessconf->locpost = strchr(fields[1], 'L') != NULL;
     PERMaccessconf->allowihave = strchr(fields[1], 'I') != NULL;
     PERMaccessconf->allownewnews = strchr(fields[1], 'N') != NULL;
-    snprintf(PERMuser, sizeof(PERMuser), "%s@%s", fields[2], fields[0]);
+    strlcpy(PERMuser, fields[2], sizeof(PERMuser));
+    strlcat(PERMuser, "@", sizeof(PERMuser));
+    strlcat(PERMuser, fields[0], sizeof(PERMuser));
     //strlcpy(PERMpass, fields[3], sizeof(PERMpass));
     strlcpy(accesslist, fields[4], size);
 

Modified: nnrpd/tls.c
===================================================================
--- nnrpd/tls.c	2019-05-30 14:16:50 UTC (rev 10341)
+++ nnrpd/tls.c	2019-05-30 14:18:48 UTC (rev 10342)
@@ -881,8 +881,9 @@
     bytes += vector[i].iov_len;
   /* Allocate a buffer to hold the data. */
   if (NULL == buffer) {
-    buffer = (char *) xmalloc(bytes);
-    allocsize = bytes;
+    size_t to_alloc = (bytes > 0 ? bytes : 1);
+    buffer = (char *) xmalloc(to_alloc);
+    allocsize = to_alloc;
   } else if (bytes > allocsize) {
     buffer = (char *) xrealloc (buffer, bytes);
     allocsize = bytes;

Modified: storage/buffindexed/buffindexed.c
===================================================================
--- storage/buffindexed/buffindexed.c	2019-05-30 14:16:50 UTC (rev 10341)
+++ storage/buffindexed/buffindexed.c	2019-05-30 14:18:48 UTC (rev 10342)
@@ -552,9 +552,13 @@
  
   memset(&rpx, 0, sizeof(OVBUFFHEAD));
   ovbuff->updated = time(NULL);
+  /* Don't use sprintf() or strlcat() directly...
+   * The terminating '\0' causes grief. */
+#if __GNUC__ > 7
+# pragma GCC diagnostic ignored "-Wstringop-truncation"
+#endif
   strncpy(rpx.magic, OVBUFF_MAGIC, strlen(OVBUFF_MAGIC));
   strncpy(rpx.path, ovbuff->path, OVBUFFPASIZ);
-  /* Don't use sprintf() directly ... the terminating '\0' causes grief */
   strncpy(rpx.indexa, offt2hex(ovbuff->index, true), OVBUFFLASIZ);
   strncpy(rpx.lena, offt2hex(ovbuff->len, true), OVBUFFLASIZ);
   strncpy(rpx.totala, offt2hex(ovbuff->totalblk, true), OVBUFFLASIZ);
@@ -561,6 +565,9 @@
   strncpy(rpx.useda, offt2hex(ovbuff->usedblk, true), OVBUFFLASIZ);
   strncpy(rpx.freea, offt2hex(ovbuff->freeblk, true), OVBUFFLASIZ);
   strncpy(rpx.updateda, offt2hex(ovbuff->updated, true), OVBUFFLASIZ);
+#if __GNUC__ > 7
+# pragma GCC diagnostic warning "-Wstringop-truncation"
+#endif
   rpx.version = OVBUFF_VERSION;
   rpx.freeblk = ovbuff->freeblk;
   rpx.usedblk = ovbuff->usedblk;

Modified: storage/cnfs/cnfs.c
===================================================================
--- storage/cnfs/cnfs.c	2019-05-30 14:16:50 UTC (rev 10341)
+++ storage/cnfs/cnfs.c	2019-05-30 14:18:48 UTC (rev 10342)
@@ -234,6 +234,11 @@
   memset(&rpx, 0, sizeof(CYCBUFFEXTERN));
   if (cycbuff->magicver == 3 || cycbuff->magicver == 4) {
     cycbuff->updated = time(NULL);
+    /* Don't use sprintf() or strlcat() directly...
+     * The terminating '\0' causes grief. */
+#if __GNUC__ > 7
+# pragma GCC diagnostic ignored "-Wstringop-truncation"
+#endif
     if (cycbuff->magicver == 3)
 	strncpy(rpx.magic, CNFS_MAGICV3, strlen(CNFS_MAGICV3));
     else
@@ -240,7 +245,6 @@
 	strncpy(rpx.magic, CNFS_MAGICV4, strlen(CNFS_MAGICV4));
     strncpy(rpx.name, cycbuff->name, CNFSNASIZ);
     strncpy(rpx.path, cycbuff->path, CNFSPASIZ);
-    /* Don't use sprintf() directly ... the terminating '\0' causes grief */
     strncpy(rpx.lena, CNFSofft2hex(cycbuff->len, true), CNFSLASIZ);
     strncpy(rpx.freea, CNFSofft2hex(cycbuff->free, true), CNFSLASIZ);
     strncpy(rpx.cyclenuma, CNFSofft2hex(cycbuff->cyclenum, true), CNFSLASIZ);
@@ -253,6 +257,9 @@
 	strncpy(rpx.currentbuff, "FALSE", CNFSMASIZ);
     }
     strncpy(rpx.blksza, CNFSofft2hex(cycbuff->blksz, true), CNFSLASIZ);
+#if __GNUC__ > 7
+# pragma GCC diagnostic warning "-Wstringop-truncation"
+#endif
     memcpy(cycbuff->bitfield, &rpx, sizeof(CYCBUFFEXTERN));
     msync(cycbuff->bitfield, cycbuff->minartoffset, MS_ASYNC);
     cycbuff->needflush = false;
@@ -660,7 +667,7 @@
 	strncpy(buf, rpx->cyclenuma, CNFSLASIZ);
         buf[CNFSLASIZ] = '\0';
 	cycbuff->cyclenum = CNFShex2offt(buf);
-	strncpy(cycbuff->metaname, rpx->metaname, CNFSLASIZ);
+	strncpy(cycbuff->metaname, rpx->metaname, CNFSNASIZ);
 	strncpy(buf, rpx->orderinmeta, CNFSLASIZ);
 	cycbuff->order = CNFShex2offt(buf);
 	if (strncmp(rpx->currentbuff, "TRUE", CNFSMASIZ) == 0) {
@@ -690,7 +697,7 @@
 	cycbuff->needflush = true;
 	cycbuff->blksz = CNFS_DFL_BLOCKSIZE;
 	cycbuff->free = 0;
-	memset(cycbuff->metaname, '\0', CNFSLASIZ);
+	memset(cycbuff->metaname, '\0', CNFSNASIZ);
     }
     /*
     ** The minimum article offset will be the size of the bitfield itself,
@@ -734,7 +741,15 @@
       /* this cycbuff is moved from other metacycbuff , or is new */
       cycbuff->order = i + 1;
       cycbuff->currentbuff = false;
-      strncpy(cycbuff->metaname, metacycbuff->name, CNFSLASIZ);
+      /* Don't use sprintf() or strlcat() directly...
+       * The terminating '\0' causes grief. */
+#if __GNUC__ > 7
+# pragma GCC diagnostic ignored "-Wstringop-truncation"
+#endif
+      strncpy(cycbuff->metaname, metacycbuff->name, CNFSNASIZ);
+#if __GNUC__ > 7
+# pragma GCC diagnostic warning "-Wstringop-truncation"
+#endif
       cycbuff->needflush = true;
       continue;
     }

Modified: storage/timecaf/caf.c
===================================================================
--- storage/timecaf/caf.c	2019-05-30 14:16:50 UTC (rev 10341)
+++ storage/timecaf/caf.c	2019-05-30 14:18:48 UTC (rev 10342)
@@ -687,7 +687,7 @@
     }
 
     /* Initialize the header. */
-    strncpy(head.Magic, CAF_MAGIC, CAF_MAGIC_LEN);
+    memcpy(head.Magic, CAF_MAGIC, CAF_MAGIC_LEN);
     head.Low = artnum;
     head.High = artnum;
     head.NumSlots = tocsize;



More information about the inn-committers mailing list