diff options
author | Ravishankar N <ravishankar@redhat.com> | 2013-07-08 15:45:54 +0530 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2013-09-09 17:21:44 -0700 |
commit | f7f12d1fc644e400eec58944a24c7f7b16f41530 (patch) | |
tree | f599122710ab99d07937cb41c9cdb5890df70d92 | |
parent | 975d0c003ac77a28be2847fb96a8a86251ee08b2 (diff) |
cli: check for null in is_server_debug_xlator()
Command: gluster volume set <volname> diagnostics.client-log-level trace
Expected output:
"volume set: failed: option log-level trace: 'trace' is not valid
(possible options are DEBUG, WARNING, ERROR, INFO, CRITICAL, NONE,
TRACE.)"
Current output: gluster cli receives a segmentation fault
Fix: check for NULL before calling strstr
Change-Id: If4c7a85a635849a388cf122543e12349c109643c
BUG: 982174
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
Reviewed-on: http://review.gluster.org/5298
Reviewed-by: Kaushal M <kaushal@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-on: http://review.gluster.org/5814
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
-rw-r--r-- | cli/src/cli-rpc-ops.c | 2 | ||||
-rw-r--r-- | tests/bugs/bug-982174.t | 36 |
2 files changed, 38 insertions, 0 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index ca96ae871..5a13ff165 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -1560,6 +1560,8 @@ is_server_debug_xlator (void *myframe) key = *words; words++; value = *words; + if (value == NULL) + break; if (strstr (value, "client")) { words++; continue; diff --git a/tests/bugs/bug-982174.t b/tests/bugs/bug-982174.t new file mode 100644 index 000000000..460af7511 --- /dev/null +++ b/tests/bugs/bug-982174.t @@ -0,0 +1,36 @@ +#!/bin/bash +# Test to check +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +#Check if incorrect log-level keywords does not crash the CLI +cleanup; + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 $H0:$B0/brick1 $H0:$B0/brick2 +TEST $CLI volume start $V0 + +function set_log_level_status { + local level=$1 + $CLI volume set $V0 diagnostics.client-log-level $level 2>&1 |grep -oE 'success|failed' +} + + +LOG_LEVEL="trace" +EXPECT "failed" set_log_level_status $LOG_LEVEL + + +LOG_LEVEL="error-gen" +EXPECT "failed" set_log_level_status $LOG_LEVEL + + +LOG_LEVEL="TRACE" +EXPECT "success" set_log_level_status $LOG_LEVEL + +EXPECT "$LOG_LEVEL" echo `$CLI volume info | grep diagnostics | awk '{print $2}'` + +TEST $CLI volume stop $V0; +TEST $CLI volume delete $V0; + +cleanup; |