mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-10-07 04:02:23 +03:00
cmHexFileConverter: Avoid stack buffer overflow
Prevent overflow on maliciously-crafted Motorola S1 record files which have a maximum line length over the 256-byte maximum.
This commit is contained in:
1 parent
afad360df9
commit
2e55f86bb3
3 files changed
+10
No files matched your search
@@ -45,6 +45,10 @@ static bool OutputBin(FILE* file, char const* buf, unsigned int startIndex,
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
if (outBufCount >= sizeof(outBuf)) {
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
outBuf[outBufCount] = static_cast<char>(convertedByte & 0xff);
|
||||
outBufCount++;
|
||||
}
|
||||
|
||||
@@ -55,6 +55,10 @@ else()
|
||||
"file(STRINGS) incorrectly read from srec file [${infile_strings}]")
|
||||
endif()
|
||||
|
||||
# this file is crafted to contain the maximum line length and trigger a buffer
|
||||
# overflow
|
||||
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/s1-max-length.srec" infile_strings)
|
||||
|
||||
#this file has utf-8 content
|
||||
file(STRINGS test.utf8 infile_strings ENCODING UTF-8)
|
||||
list(LENGTH infile_strings content_len)
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
S107000001020304EE
|
||||
S1FF000041414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414100
|
||||
Reference in new issue
Block a user