]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
butc: -Wformat-truncation fallout
authorBenjamin Kaduk <kaduk@mit.edu>
Sat, 2 Feb 2019 21:44:54 +0000 (15:44 -0600)
committerStephan Wiesand <stephan.wiesand@desy.de>
Sat, 25 Jan 2020 20:38:38 +0000 (15:38 -0500)
Increase some buffer sizes to appease gcc8.  While here, use snprintf
instead of plain sprintf(!).

Reviewed-on: https://gerrit.openafs.org/13468
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit a89297a066d8689f8fc29a7428cfe3ed6235d010)

Change-Id: If26312359d62649077e1f8adf2c9e0b39d28496f
Reviewed-on: https://gerrit.openafs.org/13737
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
src/butc/tcmain.c

index cbd135b09c2def85d8fae2b609666d83fdd5e46b..e8a20938e7dc0f2677f17f0c6d7014c6a18e5cb1 100644 (file)
@@ -69,9 +69,9 @@
 struct ubik_client *cstruct;
 FILE *logIO, *ErrorlogIO, *centralLogIO, *lastLogIO;
 char lFile[AFSDIR_PATH_MAX];
-char logFile[256];
-char ErrorlogFile[256];
-char lastLogFile[256];
+char logFile[AFSDIR_PATH_MAX + 256];
+char ErrorlogFile[AFSDIR_PATH_MAX + 256];
+char lastLogFile[AFSDIR_PATH_MAX + 256];
 char eFile[AFSDIR_PATH_MAX];
 char tapeConfigFile[AFSDIR_PATH_MAX];
 char pFile[AFSDIR_PATH_MAX];
@@ -403,7 +403,7 @@ GetDeviceConfig(char *filename, struct tapeConfig *config, afs_int32 portOffset)
 static afs_int32
 GetConfigParams(char *filename, afs_int32 port)
 {
-    char paramFile[256];
+    char paramFile[AFSDIR_PATH_MAX + 257];
     FILE *devFile = 0;
     char line[LINESIZE], cmd[LINESIZE], value[LINESIZE];
     afs_int32 code = 0;
@@ -437,13 +437,13 @@ GetConfigParams(char *filename, afs_int32 port)
     groupId = 0;               /* Group id for multiple dumps */
 
     /* Try opening the CFG_<port> file */
-    sprintf(paramFile, "%s_%d", filename, port);
+    snprintf(paramFile, sizeof(paramFile), "%s_%d", filename, port);
     devFile = fopen(paramFile, "r");
     if (devFile) {
        /* Set log names to TL_<port>, TL_<port>.lp and TE_<port> */
-       sprintf(logFile, "%s_%d", lFile, port);
-       sprintf(lastLogFile, "%s_%d.lp", lFile, port);
-       sprintf(ErrorlogFile, "%s_%d", eFile, port);
+       snprintf(logFile, sizeof(logFile), "%s_%d", lFile, port);
+       snprintf(lastLogFile, sizeof(lastLogFile), "%s_%d.lp", lFile, port);
+       snprintf(ErrorlogFile, sizeof(ErrorlogFile), "%s_%d", eFile, port);
     } else if (CONF_XBSA) {
        /* If configured as XBSA, a configuration file CFG_<port> must exist */
        printf("Cannot open configuration file %s", paramFile);