mkvers: fix potential buffer overflow 57/12657/2
authorChristof Hanke <christof.hanke@rzg.mpg.de>
Tue, 18 Jul 2017 10:04:11 +0000 (12:04 +0200)
committerBenjamin Kaduk <kaduk@mit.edu>
Tue, 18 Jul 2017 18:05:32 +0000 (14:05 -0400)
The space allocated for outputFileBuf is only 2 bytes larger than
sizeof(VERS_FILE). But we add potentially 4 extra bytes like
".txt" or ".xml". Just allocate enough space for all file suffices.

Change-Id: Ic0f97590be208deaf9c4a5c25e21056ea9d2cd6f
Reviewed-on: https://gerrit.openafs.org/12657
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

src/config/mkvers.c

index d0565ce..fca18d0 100644 (file)
@@ -95,7 +95,7 @@ main(int argc, char **argv)
     char *baseDir;
     int argDir = 0;
     char *outputFile = NULL;
-    char outputFileBuf[sizeof(VERS_FILE) + 2];
+    char outputFileBuf[sizeof(VERS_FILE) + 4];
     struct stat sbuf;
     time_t versTime;
     int reBuild = 0;