mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-10 07:40:03 -06:00
Corruption happens when a multiline help string starts with a newline. This causes an overflow in substr() and the whole, unescaped help string is written to the cache file. Multiline strings are escaped line by line. The fix is to start searching for line break points from position 1. A break point at zero, which triggers the overflow, could only produce a redundant empty line. Fixes: #9098
22 lines
544 B
CMake
22 lines
544 B
CMake
# Various newline possibilities
|
|
|
|
set(help_strings
|
|
"\n"
|
|
"\n\n\n"
|
|
"\n \n"
|
|
"\nline1"
|
|
"line1\n"
|
|
"\nline1\n"
|
|
"line1\nline2\nline3"
|
|
"\nline1\nline2\nline3\n"
|
|
"
|
|
line line line line line line line line line line line line line line line line
|
|
line line line line line line line line line line line line line line line line
|
|
line line line line line line line line line line line line line line line line"
|
|
)
|
|
|
|
foreach(help IN LISTS help_strings)
|
|
string(SHA1 name "${help}")
|
|
set("${name}" "" CACHE STRING "${help}" FORCE)
|
|
endforeach()
|