1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-14 10:13:05 +02:00

Fix buffer underrun in configuration test harness.

If the total bytes read from the expect log file was 0 then the last byte of whatever was in memory before harnessLogBuffer would be set to 0.

On 32-bit systems this expressed as the high order byte of a pointer being cleared and wackiness (in the form of segfaults) ensued.
This commit is contained in:
David Steele 2018-09-16 13:41:49 -04:00
parent 0c02481d6e
commit 3014b05dab
2 changed files with 6 additions and 1 deletions

View File

@ -105,6 +105,10 @@
<release-test-list> <release-test-list>
<release-development-list> <release-development-list>
<release-item>
<p>Fix buffer underrun in configuration test harness.</p>
</release-item>
<release-item> <release-item>
<p>Make Valgrind return an error even when a non-fatal issue is detected. Update some minor issues discovered in the tests as a result.</p> <p>Make Valgrind return an error even when a non-fatal issue is detected. Update some minor issues discovered in the tests as a result.</p>
</release-item> </release-item>

View File

@ -142,7 +142,8 @@ harnessLogLoad(const char *logFile)
THROW_SYS_ERROR_FMT(FileOpenError, "unable to close log file '%s'", logFile); THROW_SYS_ERROR_FMT(FileOpenError, "unable to close log file '%s'", logFile);
// Remove final linefeed // Remove final linefeed
harnessLogBuffer[totalBytes - 1] = 0; if (totalBytes > 0)
harnessLogBuffer[totalBytes - 1] = 0;
FUNCTION_HARNESS_RESULT_VOID(); FUNCTION_HARNESS_RESULT_VOID();
} }