mirror of
https://github.com/postgres/postgres.git
synced 2025-06-29 10:41:53 +03:00
Add additional safety check against invalid backup label file
It was already checking for invalid data after "BACKUP FROM", but would possibly crash if "BACKUP FROM" was missing altogether. found by Coverity
This commit is contained in:
@ -9481,7 +9481,7 @@ do_pg_stop_backup(char *labelfile, bool waitforarchive)
|
|||||||
* during the backup.
|
* during the backup.
|
||||||
*/
|
*/
|
||||||
ptr = strstr(remaining, "BACKUP FROM:");
|
ptr = strstr(remaining, "BACKUP FROM:");
|
||||||
if (sscanf(ptr, "BACKUP FROM: %19s\n", backupfrom) != 1)
|
if (!ptr || sscanf(ptr, "BACKUP FROM: %19s\n", backupfrom) != 1)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||||
errmsg("invalid data in file \"%s\"", BACKUP_LABEL_FILE)));
|
errmsg("invalid data in file \"%s\"", BACKUP_LABEL_FILE)));
|
||||||
|
Reference in New Issue
Block a user