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 <ggarg@redhat.com>
Reviewed-on: http://review.gluster.org/13060
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
This commit is contained in:
Gaurav Kumar Garg 2015-12-22 12:05:39 +05:30 committed by Atin Mukherjee
parent a370013898
commit e4de816ae1

View File

@ -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;