INN commit: trunk/storage/cnfs (cnfs.c)

INN Commit rra at isc.org
Thu May 30 14:16:51 UTC 2019


    Date: Thursday, May 30, 2019 @ 07:16:50
  Author: iulius
Revision: 10341

CNFS:  Use CNFSNASIZ when appropriate (for buffer names)

Note that CNFSLASIZ and CNFSNASIZ have the same value (16) so it does not
change anything.  In case the value changes in the future, it will break
so we prevent that with the following patch.

Modified:
  trunk/storage/cnfs/cnfs.c

--------+
 cnfs.c |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

Modified: cnfs.c
===================================================================
--- cnfs.c	2019-05-30 13:58:41 UTC (rev 10340)
+++ cnfs.c	2019-05-30 14:16:50 UTC (rev 10341)
@@ -667,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) {
@@ -697,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,
@@ -741,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;
     }



More information about the inn-committers mailing list