From 3ff2378dcf9e9a0bb031b7032bf68d986da74943 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Tue, 7 Mar 2017 14:13:10 +1100 Subject: [PATCH] ctdb-tools: Avoid deferencing argv[0] if argc == 0 BUG: https://bugzilla.samba.org/show_bug.cgi?id=12723 Signed-off-by: Amitay Isaacs Reviewed-by: Martin Schwenke Autobuild-User(master): Martin Schwenke Autobuild-Date(master): Wed Mar 29 11:07:18 CEST 2017 on sn-devel-144 (cherry picked from commit 6e9879f6e2f8974730517fad22875db06f0738de) --- ctdb/tools/ctdb_event.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ctdb/tools/ctdb_event.c b/ctdb/tools/ctdb_event.c index 62b4b91..8e2dca7 100644 --- a/ctdb/tools/ctdb_event.c +++ b/ctdb/tools/ctdb_event.c @@ -223,23 +223,26 @@ static int command_status(TALLOC_CTX *mem_ctx, struct tool_context *tctx, talloc_free(req); if (! status) { fprintf(stderr, "Failed to get event %s status, ret=%d\n", - argv[0], ret); + ctdb_event_to_string(event), ret); return ret; } if (result != 0) { fprintf(stderr, "Failed to get event %s status, result=%d\n", - argv[0], result); + ctdb_event_to_string(event), result); return result; } if (script_list == NULL) { if (state == CTDB_EVENT_LAST_RUN) { - printf("Event %s has never run\n", argv[0]); + printf("Event %s has never run\n", + ctdb_event_to_string(event)); } else if (state == CTDB_EVENT_LAST_PASS) { - printf("Event %s has never passed\n", argv[0]); + printf("Event %s has never passed\n", + ctdb_event_to_string(event)); } else if (state == CTDB_EVENT_LAST_FAIL) { - printf("Event %s has never failed\n", argv[0]); + printf("Event %s has never failed\n", + ctdb_event_to_string(event)); } } else { for (i=0; inum_scripts; i++) { -- 2.9.3