From: Adam Kwolek Date: Tue, 7 Feb 2012 14:03:03 +0000 (+0100) Subject: FIX: NULL pointer to strdup() can be passed X-Git-Tag: mdadm-3.2.4~89 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92d49ecfaabcd015cf9957a0863996eaa5755747;p=thirdparty%2Fmdadm.git FIX: NULL pointer to strdup() can be passed When result from strchr() is NULL and it is assigned to subarray, NULL pointer can be passed to strdup() function and coredump file is generated. Subarray is checked for NULL pointer, so it is assumed that it can be NULL at this moment. Signed-off-by: Adam Kwolek Signed-off-by: NeilBrown --- diff --git a/util.c b/util.c index e5f7a202..7abbff75 100644 --- a/util.c +++ b/util.c @@ -966,9 +966,10 @@ struct supertype *super_by_fd(int fd, char **subarrayp) char *dev = verstr+1; subarray = strchr(dev, '/'); - if (subarray) + if (subarray) { *subarray++ = '\0'; - subarray = strdup(subarray); + subarray = strdup(subarray); + } container = devname2devnum(dev); if (sra) sysfs_free(sra);