mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-02-08 14:28:36 +02:00
Always return an error in case of incorrect backup mode
Some code paths allowed an invalid backup mode to be passed, something rather crazy as they directly depended on that...
This commit is contained in:
parent
9ecd5acb97
commit
83f4e80a74
11
catalog.c
11
catalog.c
@ -492,7 +492,7 @@ catalog_read_ini(const char *path)
|
||||
|
||||
if (backup_mode)
|
||||
{
|
||||
backup->backup_mode = parse_backup_mode(backup_mode, WARNING);
|
||||
backup->backup_mode = parse_backup_mode(backup_mode);
|
||||
free(backup_mode);
|
||||
}
|
||||
|
||||
@ -545,12 +545,14 @@ catalog_read_ini(const char *path)
|
||||
}
|
||||
|
||||
BackupMode
|
||||
parse_backup_mode(const char *value, int elevel)
|
||||
parse_backup_mode(const char *value)
|
||||
{
|
||||
const char *v = value;
|
||||
size_t len;
|
||||
|
||||
while (IsSpace(*v)) { v++; }
|
||||
/* Skip all spaces detected */
|
||||
while (IsSpace(*v))
|
||||
v++;
|
||||
len = strlen(v);
|
||||
|
||||
if (len > 0 && pg_strncasecmp("full", v, len) == 0)
|
||||
@ -560,7 +562,8 @@ parse_backup_mode(const char *value, int elevel)
|
||||
else if (len > 0 && pg_strncasecmp("archive", v, len) == 0)
|
||||
return BACKUP_MODE_ARCHIVE;
|
||||
|
||||
elog(elevel, _("invalid backup-mode \"%s\""), value);
|
||||
/* Backup mode is invalid, so leave with an error */
|
||||
elog(ERROR_ARGS, _("invalid backup-mode \"%s\""), value);
|
||||
return BACKUP_MODE_INVALID;
|
||||
}
|
||||
|
||||
|
@ -330,5 +330,5 @@ if(!IsValidTime(tm)){
|
||||
static void
|
||||
opt_backup_mode(pgut_option *opt, const char *arg)
|
||||
{
|
||||
current.backup_mode = parse_backup_mode(arg, ERROR_ARGS);
|
||||
current.backup_mode = parse_backup_mode(arg);
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ extern const char *pgdata_exclude[];
|
||||
|
||||
/* in backup.c */
|
||||
extern int do_backup(pgBackupOption bkupopt);
|
||||
extern BackupMode parse_backup_mode(const char *value, int elevel);
|
||||
extern BackupMode parse_backup_mode(const char *value);
|
||||
extern void check_server_version(void);
|
||||
extern bool fileExists(const char *path);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user