From e4de816ae126b62906afcc1ce1216500b517e222 Mon Sep 17 00:00:00 2001 From: Gaurav Kumar Garg Date: Tue, 22 Dec 2015 12:05:39 +0530 Subject: cli: should not dereference NULL pointer while printing bitrot scrub status When user execute bitrot scrub status command and scrubber is pending to do scrubbing then value of last_scrub time will be NULL. Currently cli is dereferencing NULL pointer in this case, That might lead to crash. Fix is to use proper check condition while printing scrub status. Change-Id: I3c4be8e25d089451c6ab77b16737c01d0348ee70 BUG: 1293558 Signed-off-by: Gaurav Kumar Garg Reviewed-on: http://review.gluster.org/13060 Reviewed-by: Atin Mukherjee Tested-by: Gluster Build System Tested-by: NetBSD Build System --- cli/src/cli-rpc-ops.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'cli/src') diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 6288b01a6af..da9df4cc05e 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -10849,9 +10849,12 @@ gf_cli_print_bitrot_scrub_status (dict_t *dict) cli_out ("%s: %"PRIu64 "\n", "Number of Unsigned files", unsigned_files); - cli_out ("%s: %s\n", "Last completed scrub time", - (*last_scrub) ? last_scrub : "Scrubber pending to " - "complete."); + if ((!last_scrub) || !strcmp (last_scrub, "")) + cli_out ("%s: %s\n", "Last completed scrub time", + "Scrubber pending to complete."); + else + cli_out ("%s: %s\n", "Last completed scrub time", + last_scrub); /* Printing last scrub duration time in human readable form*/ days = scrub_time/86400; -- cgit