From 79613af8d0942343598fc45a28bd187921cc7b50 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Thu, 28 Mar 2019 12:45:53 +0900 Subject: [PATCH] Handle potential NULL return from string_skip_prefix() --- repmgr-action-standby.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/repmgr-action-standby.c b/repmgr-action-standby.c index 4409aef4..a9651b60 100644 --- a/repmgr-action-standby.c +++ b/repmgr-action-standby.c @@ -6084,10 +6084,11 @@ run_file_backup(t_node_info *node_record) * Remove prefix */ p = string_skip_prefix(prefix, output); + if (p == NULL) { - log_error("unexpected output from \"barman list-files\": %s", - output); + log_error("unexpected output from \"barman list-files\""); + log_detail("%s", output); exit(ERR_BARMAN); } @@ -6105,6 +6106,14 @@ run_file_backup(t_node_info *node_record) strncat(prefix, backup_id, MAXLEN - 1); strncat(prefix, "/", MAXLEN - 1); p = string_skip_prefix(backup_id, p); + + if (p == NULL) + { + log_error("unexpected output from \"barman list-files\""); + log_detail("%s", output); + exit(ERR_BARMAN); + } + p = string_skip_prefix("/", p); /* @@ -6116,8 +6125,8 @@ run_file_backup(t_node_info *node_record) basebackups_directory, backup_id, local_repmgr_tmp_directory); - (void) local_command( - command, + + (void) local_command(command, NULL); /*