Fixed unsafe string copy and concat in fileio.c.
Per warnings from flawfinder: "Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused).". Replaced called to strcpy and strcat in `fileio.c` to calls with a specified size (`strncpy` and `strncat`). Tested the changes on OSX, Linux, Windows. On OSX + Linux, changes were tested with ASAN. The following flags were used: 'check_initialization_order=1:strict_init_order=1:detect_odr_violation=1:detect_stack_use_after_return=1' To reproduce warning: ./flawfinder.py ./programs/fileio.c
This commit is contained in:
+2
-2
@@ -1011,8 +1011,8 @@ int FIO_compressMultipleFilenames(const char** inFileNamesTable, unsigned nbFile
|
|||||||
if (!dstFileName) {
|
if (!dstFileName) {
|
||||||
EXM_THROW(30, "zstd: %s", strerror(errno));
|
EXM_THROW(30, "zstd: %s", strerror(errno));
|
||||||
} }
|
} }
|
||||||
strcpy(dstFileName, inFileNamesTable[u]);
|
strncpy(dstFileName, inFileNamesTable[u], ifnSize+1 /* Include null */);
|
||||||
strcat(dstFileName, suffix);
|
strncat(dstFileName, suffix, suffixSize);
|
||||||
missed_files += FIO_compressFilename_dstFile(ress, dstFileName, inFileNamesTable[u], compressionLevel);
|
missed_files += FIO_compressFilename_dstFile(ress, dstFileName, inFileNamesTable[u], compressionLevel);
|
||||||
} }
|
} }
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ invalidDictionaries
|
|||||||
checkTag
|
checkTag
|
||||||
zcat
|
zcat
|
||||||
zstdcat
|
zstdcat
|
||||||
|
tm
|
||||||
|
|
||||||
# Tmp test directory
|
# Tmp test directory
|
||||||
zstdtest
|
zstdtest
|
||||||
|
|||||||
Reference in New Issue
Block a user