From 5d88111a142b3c37e92bdd36699a04fd054d27f4 Mon Sep 17 00:00:00 2001 From: Xavi Hernandez Date: Wed, 22 May 2019 17:46:19 +0200 Subject: Fix some "Null pointer dereference" coverity issues This patch fixes the following CID's: * 1124829 * 1274075 * 1274083 * 1274128 * 1274135 * 1274141 * 1274143 * 1274197 * 1274205 * 1274210 * 1274211 * 1288801 * 1398629 Change-Id: Ia7c86cfab3245b20777ffa296e1a59748040f558 Updates: bz#789278 Signed-off-by: Xavi Hernandez --- glusterfsd/src/glusterfsd.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'glusterfsd') diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index e85db1d3507..f1b7d742fbc 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -1241,19 +1241,21 @@ parse_opts(int key, char *arg, struct argp_state *state) case ARGP_BRICK_PORT_KEY: n = 0; - port_str = strtok_r(arg, ",", &tmp_str); - if (gf_string2uint_base10(port_str, &n) == 0) { - cmd_args->brick_port = n; - port_str = strtok_r(NULL, ",", &tmp_str); - if (port_str) { - if (gf_string2uint_base10(port_str, &n) == 0) { - cmd_args->brick_port2 = n; - break; + if (arg != NULL) { + port_str = strtok_r(arg, ",", &tmp_str); + if (gf_string2uint_base10(port_str, &n) == 0) { + cmd_args->brick_port = n; + port_str = strtok_r(NULL, ",", &tmp_str); + if (port_str) { + if (gf_string2uint_base10(port_str, &n) == 0) { + cmd_args->brick_port2 = n; + break; + } + argp_failure(state, -1, 0, + "wrong brick (listen) port %s", arg); } - argp_failure(state, -1, 0, "wrong brick (listen) port %s", - arg); + break; } - break; } argp_failure(state, -1, 0, "unknown brick (listen) port %s", arg); -- cgit