You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-15 01:04:37 +02:00
Check that sha1 checksum is not empty in manifestFileUpdate().
The manifest test module was setting a blank value here and causing a stack overflow because memcpy() is used instead of strcpy(). This was really just a test issue but add an assert just in case the same were to happen in production code. Also update a bogus checksum in the integration tests to the correct length to avoid running afoul of the assert. Found with -fsanitize=address.
This commit is contained in:
@ -2820,7 +2820,10 @@ manifestFileUpdate(
|
||||
|
||||
// Update checksum if set
|
||||
if (checksumSha1 != NULL)
|
||||
{
|
||||
ASSERT(strlen(checksumSha1) == HASH_TYPE_SHA1_SIZE_HEX);
|
||||
memcpy(file.checksumSha1, checksumSha1, HASH_TYPE_SHA1_SIZE_HEX + 1);
|
||||
}
|
||||
|
||||
// Update repo size
|
||||
file.size = size;
|
||||
|
@ -784,7 +784,8 @@ sub run
|
||||
$oHostBackup->manifestMunge(
|
||||
basename($strResumePath),
|
||||
{&MANIFEST_SECTION_TARGET_FILE =>
|
||||
{(&MANIFEST_TARGET_PGDATA . '/badchecksum.txt') => {&MANIFEST_SUBKEY_CHECKSUM => BOGUS}}},
|
||||
{(&MANIFEST_TARGET_PGDATA . '/badchecksum.txt') =>
|
||||
{&MANIFEST_SUBKEY_CHECKSUM => 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'}}},
|
||||
false);
|
||||
}
|
||||
# Change contents of resumed file without changing size so it will throw a nasty error about the repo having been corrupted
|
||||
|
@ -1747,9 +1747,12 @@ testRun(void)
|
||||
"pg_data/special-@#!$^&*()_+~`{}[]\\:;", "find special file");
|
||||
TEST_RESULT_BOOL(manifestFileExists(manifest, STRDEF("bogus")), false, "manifest file does not exist");
|
||||
|
||||
TEST_RESULT_VOID(
|
||||
manifestFileUpdate(manifest, STRDEF("pg_data/postgresql.conf"), 4457, 4457, "", NULL, false, false, NULL, 0, 0),
|
||||
"update file");
|
||||
// Munge the sha1 checksum to be blank
|
||||
ManifestFilePack **const fileMungePack = manifestFilePackFindInternal(manifest, STRDEF("pg_data/postgresql.conf"));
|
||||
ManifestFile fileMunge = manifestFileUnpack(manifest, *fileMungePack);
|
||||
fileMunge.checksumSha1[0] = '\0';
|
||||
manifestFilePackUpdate(manifest, fileMungePack, &fileMunge);
|
||||
|
||||
TEST_RESULT_VOID(
|
||||
manifestFileUpdate(
|
||||
manifest, STRDEF("pg_data/postgresql.conf"), 4457, 4457, NULL, varNewStr(NULL), false, false, NULL, 0, 0),
|
||||
|
Reference in New Issue
Block a user