diff options
author | Adam Kwolek <adam.kwolek@intel.com> | 2012-02-07 15:03:03 +0100 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2012-02-09 12:20:51 +1100 |
commit | 92d49ecfaabcd015cf9957a0863996eaa5755747 (patch) | |
tree | bf209bd220cc4818ebb9001f6a9f31547dec4e7d | |
parent | b10c663ea941fccd80ff8ace69ae4ffc0bdfbcd3 (diff) | |
download | mdadm-92d49ecfaabcd015cf9957a0863996eaa5755747.tar.gz |
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 <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
-rw-r--r-- | util.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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); |