[stgt] [PATCH] Fix possible segfault on logicalunit update

Roi Dayan roid at mellanox.com
Wed Aug 28 18:18:13 CEST 2013


When updating logicalunit with tgtdadm without any params
tgtd will segfault when calling strncmp on NULL.
The call to strsep later is ok and will return NULL.

To reproduce create a target with a lun and run:
tgtadm -m logicalunit -o update --tid 1 --lun 1

Signed-off-by: Roi Dayan <roid at mellanox.com>
---
 usr/spc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/usr/spc.c b/usr/spc.c
index 15077ca..00e0dd7 100644
--- a/usr/spc.c
+++ b/usr/spc.c
@@ -1921,7 +1921,7 @@ tgtadm_err lu_config(struct scsi_lu *lu, char *params, match_fn_t *fn)
 	attrs = &lu->attrs;
 	lu_vpd = attrs->lu_vpd;
 
-	if (!strncmp("targetOps", params, 9))
+	if (params && !strncmp("targetOps", params, 9))
 		params = params + 10;
 
 	while ((p = strsep(&params, ",")) != NULL) {
-- 
1.7.8.2

--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the stgt mailing list