From: Benjamin Kaduk Date: Sat, 2 Feb 2019 21:44:54 +0000 (-0600) Subject: butc: -Wformat-truncation fallout X-Git-Tag: upstream/1.8.6_pre1^2~66 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=aa6c1946c0988439207694bc4962a2afbd2a9bd3;p=packages%2Fo%2Fopenafs.git butc: -Wformat-truncation fallout 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 Reviewed-by: Cheyenne Wills Reviewed-by: Michael Meffie Reviewed-by: Benjamin Kaduk (cherry picked from commit a89297a066d8689f8fc29a7428cfe3ed6235d010) Change-Id: If26312359d62649077e1f8adf2c9e0b39d28496f Reviewed-on: https://gerrit.openafs.org/13737 Reviewed-by: Andrew Deason Reviewed-by: Marcio Brito Barbosa Reviewed-by: Michael Meffie Tested-by: BuildBot Reviewed-by: Stephan Wiesand --- diff --git a/src/butc/tcmain.c b/src/butc/tcmain.c index cbd135b09..e8a20938e 100644 --- a/src/butc/tcmain.c +++ b/src/butc/tcmain.c @@ -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_ 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_, TL_.lp and TE_ */ - 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_ must exist */ printf("Cannot open configuration file %s", paramFile);