INN commit: trunk (6 files)

INN Commit rra at isc.org
Thu May 30 13:57:31 UTC 2019


    Date: Thursday, May 30, 2019 @ 06:57:30
  Author: iulius
Revision: 10339

Fix string operation warnings with GCC 9

Modified:
  trunk/backends/archive.c
  trunk/nnrpd/commands.c
  trunk/nnrpd/tls.c
  trunk/storage/buffindexed/buffindexed.c
  trunk/storage/cnfs/cnfs.c
  trunk/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               |    9 ++++++++-
 storage/timecaf/caf.c             |    2 +-
 6 files changed, 24 insertions(+), 7 deletions(-)

Modified: backends/archive.c
===================================================================
--- backends/archive.c	2019-05-30 13:34:05 UTC (rev 10338)
+++ backends/archive.c	2019-05-30 13:57:30 UTC (rev 10339)
@@ -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 13:34:05 UTC (rev 10338)
+++ nnrpd/commands.c	2019-05-30 13:57:30 UTC (rev 10339)
@@ -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 13:34:05 UTC (rev 10338)
+++ nnrpd/tls.c	2019-05-30 13:57:30 UTC (rev 10339)
@@ -831,8 +831,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 13:34:05 UTC (rev 10338)
+++ storage/buffindexed/buffindexed.c	2019-05-30 13:57:30 UTC (rev 10339)
@@ -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 13:34:05 UTC (rev 10338)
+++ storage/cnfs/cnfs.c	2019-05-30 13:57:30 UTC (rev 10339)
@@ -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;

Modified: storage/timecaf/caf.c
===================================================================
--- storage/timecaf/caf.c	2019-05-30 13:34:05 UTC (rev 10338)
+++ storage/timecaf/caf.c	2019-05-30 13:57:30 UTC (rev 10339)
@@ -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