butc: fix format overflow warning 98/13498/2
authorMichael Meffie <mmeffie@sinenomine.net>
Mon, 19 Feb 2018 18:57:16 +0000 (13:57 -0500)
committerStephan Wiesand <stephan.wiesand@desy.de>
Fri, 1 Mar 2019 15:10:15 +0000 (10:10 -0500)
Recent versions of gcc generate an overflow warning in the butc DUMPNAME macro
when copying values into the finishedMsg1 buffer. Increase the size of the
destination buffer to avoid a possible buffer overflow.

    dump.c:88:24: error: ‘%s’ directive writing up to 63 bytes into
    a region of size 50 [-Werror=format-overflow=]
          sprintf(dumpname, "%s (DumpId %u)", name, dbDumpId);
                            ^
    dump.c:1294:5: note: in expansion of macro ‘DUMPNAME’
         DUMPNAME(finishedMsg1, nodePtr->dumpSetName, dparams.databaseDumpId);
         ^~~~~~~~
    dump.c:88:6: note: ‘sprintf’ output between 12 and 84 bytes into
    a destination of size 50
          sprintf(dumpname, "%s (DumpId %u)", name, dbDumpId);
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    dump.c:1294:5: note: in expansion of macro ‘DUMPNAME’
         DUMPNAME(finishedMsg1, nodePtr->dumpSetName, dparams.databaseDumpId);
         ^~~~~~~~

Reviewed-on: https://gerrit.openafs.org/12916
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit cec45d59440f55316097cfd6652d2ea26cd55233)

Reviewed-on: https://gerrit.openafs.org/13097
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit dba69c2a190103d1941ca6232d9a466f259a206c)

Change-Id: Idb1bc17619018073d14f6047cad404283898a005
Reviewed-on: https://gerrit.openafs.org/13498
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Tested-by: Stephan Wiesand <stephan.wiesand@desy.de>

src/butc/dump.c

index 8fcc61a..57cfe12 100644 (file)
@@ -1142,7 +1142,7 @@ Dumper(void *param)
     int nodumpvolumes = 0;
     char strlevel[5];
     char msg[20];
-    char finishedMsg1[50];
+    char finishedMsg1[128];
     char finishedMsg2[50];
     time_t startTime = 0;
     time_t endTime = 0;