You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-17 01:12:23 +02:00
Use strNewZ() in cases where STRDEF() assignment goes out of scope.
If a variable assigned with STRDEF() is referenced out of scope of the STRDEF() assignment then the value is undefined. Luckily most of the instances are in tests but there is one in the core code. It is not clear if this is a live bug or not but it certainly needs to be fixed. Found with -fsanitize=address.
This commit is contained in:
@ -675,7 +675,7 @@ backupResumeFind(const Manifest *manifest, const String *cipherPassBackup)
|
||||
// Resumable backups must have backup.manifest.copy
|
||||
if (storageExistsP(storageRepo(), strNewFmt("%s" INFO_COPY_EXT, strZ(manifestFile))))
|
||||
{
|
||||
reason = STRDEF("resume is disabled");
|
||||
reason = strNewZ("resume is disabled");
|
||||
|
||||
// Attempt to read the manifest file in the resumable backup to see if it can be used. If any error at all
|
||||
// occurs then the backup will be considered unusable and a resume will not be attempted.
|
||||
|
@ -1748,7 +1748,7 @@ testRun(void)
|
||||
manifestResume = manifestNewInternal();
|
||||
manifestResume->pub.info = infoNew(NULL);
|
||||
manifestResume->pub.data.backupType = backupTypeFull;
|
||||
manifestResume->pub.data.backupLabel = STRDEF("20191003-105320F");
|
||||
manifestResume->pub.data.backupLabel = strNewZ("20191003-105320F");
|
||||
manifestResume->pub.data.pgVersion = PG_VERSION_12;
|
||||
}
|
||||
OBJ_NEW_END();
|
||||
|
@ -1900,7 +1900,7 @@ testRun(void)
|
||||
{
|
||||
manifest = manifestNewInternal();
|
||||
manifest->pub.info = infoNew(NULL);
|
||||
manifest->pub.data.backupLabel = STRDEF(TEST_LABEL);
|
||||
manifest->pub.data.backupLabel = strNewZ(TEST_LABEL);
|
||||
manifest->pub.data.pgVersion = PG_VERSION_90;
|
||||
manifest->pub.data.pgCatalogVersion = hrnPgCatalogVersion(PG_VERSION_90);
|
||||
manifest->pub.data.backupType = backupTypeFull;
|
||||
@ -2306,7 +2306,7 @@ testRun(void)
|
||||
{
|
||||
manifest = manifestNewInternal();
|
||||
manifest->pub.info = infoNew(NULL);
|
||||
manifest->pub.data.backupLabel = STRDEF(TEST_LABEL);
|
||||
manifest->pub.data.backupLabel = strNewZ(TEST_LABEL);
|
||||
manifest->pub.data.pgVersion = PG_VERSION_10;
|
||||
manifest->pub.data.pgCatalogVersion = hrnPgCatalogVersion(PG_VERSION_10);
|
||||
manifest->pub.data.backupType = backupTypeIncr;
|
||||
|
@ -1062,7 +1062,7 @@ testRun(void)
|
||||
OBJ_NEW_BEGIN(Manifest)
|
||||
{
|
||||
manifestPrior = manifestNewInternal();
|
||||
manifestPrior->pub.data.backupLabel = STRDEF("20190101-010101F");
|
||||
manifestPrior->pub.data.backupLabel = strNewZ("20190101-010101F");
|
||||
|
||||
manifestFileAdd(
|
||||
manifestPrior,
|
||||
|
@ -285,7 +285,7 @@ testRun(void)
|
||||
{
|
||||
protocolHelperClient.client = OBJ_NEW_ALLOC();
|
||||
*protocolHelperClient.client = (ProtocolClient){
|
||||
.name = STRDEF("test"), .state = protocolClientStateIdle, .write = write};
|
||||
.name = strNewZ("test"), .state = protocolClientStateIdle, .write = write};
|
||||
memContextCallbackSet(memContextCurrent(), protocolClientFreeResource, protocolHelperClient.client);
|
||||
}
|
||||
OBJ_NEW_END();
|
||||
@ -293,7 +293,7 @@ testRun(void)
|
||||
OBJ_NEW_BEGIN(Exec)
|
||||
{
|
||||
protocolHelperClient.exec = OBJ_NEW_ALLOC();
|
||||
*protocolHelperClient.exec = (Exec){.name = STRDEF("test"), .command = strNewZ("test"), .processId = INT_MAX};
|
||||
*protocolHelperClient.exec = (Exec){.name = strNewZ("test"), .command = strNewZ("test"), .processId = INT_MAX};
|
||||
memContextCallbackSet(memContextCurrent(), execFreeResource, protocolHelperClient.exec);
|
||||
}
|
||||
OBJ_NEW_END();
|
||||
|
Reference in New Issue
Block a user