Commit e684ab5e authored by Peter Eisentraut's avatar Peter Eisentraut

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
parent acfaa596
......@@ -9481,7 +9481,7 @@ do_pg_stop_backup(char *labelfile, bool waitforarchive)
* during the backup.
*/
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,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("invalid data in file \"%s\"", BACKUP_LABEL_FILE)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment