mirror of
https://github.com/google/googletest.git
synced 2026-04-30 19:09:20 +08:00
fix: check ftell() return value to prevent SIZE_MAX allocation
ftell() returns -1 on failure, which when cast to size_t becomes SIZE_MAX, causing new char[SIZE_MAX] to crash. Added return value check and early return with empty result on failure. Signed-off-by: Srikanth Patchava <spatchava@meta.com> Signed-off-by: Srikanth Patchava <srikanth.patchava@outlook.com>
This commit is contained in:
parent
fab81cb483
commit
96b7206ba8
0
googlemock/test/gmock_leak_test.py
Executable file → Normal file
0
googlemock/test/gmock_leak_test.py
Executable file → Normal file
0
googlemock/test/gmock_output_test.py
Executable file → Normal file
0
googlemock/test/gmock_output_test.py
Executable file → Normal file
0
googlemock/test/gmock_test_utils.py
Executable file → Normal file
0
googlemock/test/gmock_test_utils.py
Executable file → Normal file
@ -1258,7 +1258,11 @@ std::string GetCapturedStderr() {
|
||||
|
||||
size_t GetFileSize(FILE* file) {
|
||||
fseek(file, 0, SEEK_END);
|
||||
return static_cast<size_t>(ftell(file));
|
||||
const long size = ftell(file);
|
||||
if (size < 0) {
|
||||
return 0;
|
||||
}
|
||||
return static_cast<size_t>(size);
|
||||
}
|
||||
|
||||
std::string ReadEntireFile(FILE* file) {
|
||||
|
||||
0
googletest/test/googletest-break-on-failure-unittest.py
Executable file → Normal file
0
googletest/test/googletest-break-on-failure-unittest.py
Executable file → Normal file
0
googletest/test/googletest-catch-exceptions-test.py
Executable file → Normal file
0
googletest/test/googletest-catch-exceptions-test.py
Executable file → Normal file
0
googletest/test/googletest-color-test.py
Executable file → Normal file
0
googletest/test/googletest-color-test.py
Executable file → Normal file
0
googletest/test/googletest-env-var-test.py
Executable file → Normal file
0
googletest/test/googletest-env-var-test.py
Executable file → Normal file
0
googletest/test/googletest-fail-if-no-test-linked-test.py
Executable file → Normal file
0
googletest/test/googletest-fail-if-no-test-linked-test.py
Executable file → Normal file
0
googletest/test/googletest-failfast-unittest.py
Executable file → Normal file
0
googletest/test/googletest-failfast-unittest.py
Executable file → Normal file
0
googletest/test/googletest-filter-unittest.py
Executable file → Normal file
0
googletest/test/googletest-filter-unittest.py
Executable file → Normal file
0
googletest/test/googletest-list-tests-unittest.py
Executable file → Normal file
0
googletest/test/googletest-list-tests-unittest.py
Executable file → Normal file
0
googletest/test/googletest-output-test.py
Executable file → Normal file
0
googletest/test/googletest-output-test.py
Executable file → Normal file
0
googletest/test/googletest-setuptestsuite-test.py
Executable file → Normal file
0
googletest/test/googletest-setuptestsuite-test.py
Executable file → Normal file
0
googletest/test/googletest-shuffle-test.py
Executable file → Normal file
0
googletest/test/googletest-shuffle-test.py
Executable file → Normal file
0
googletest/test/googletest-throw-on-failure-test.py
Executable file → Normal file
0
googletest/test/googletest-throw-on-failure-test.py
Executable file → Normal file
0
googletest/test/googletest-uninitialized-test.py
Executable file → Normal file
0
googletest/test/googletest-uninitialized-test.py
Executable file → Normal file
0
googletest/test/gtest_help_test.py
Executable file → Normal file
0
googletest/test/gtest_help_test.py
Executable file → Normal file
0
googletest/test/gtest_skip_check_output_test.py
Executable file → Normal file
0
googletest/test/gtest_skip_check_output_test.py
Executable file → Normal file
0
googletest/test/gtest_skip_environment_check_output_test.py
Executable file → Normal file
0
googletest/test/gtest_skip_environment_check_output_test.py
Executable file → Normal file
0
googletest/test/gtest_test_utils.py
Executable file → Normal file
0
googletest/test/gtest_test_utils.py
Executable file → Normal file
0
googletest/test/gtest_testbridge_test.py
Executable file → Normal file
0
googletest/test/gtest_testbridge_test.py
Executable file → Normal file
0
googletest/test/gtest_xml_outfiles_test.py
Executable file → Normal file
0
googletest/test/gtest_xml_outfiles_test.py
Executable file → Normal file
0
googletest/test/gtest_xml_output_unittest.py
Executable file → Normal file
0
googletest/test/gtest_xml_output_unittest.py
Executable file → Normal file
0
googletest/test/gtest_xml_test_utils.py
Executable file → Normal file
0
googletest/test/gtest_xml_test_utils.py
Executable file → Normal file
Loading…
x
Reference in New Issue
Block a user