diff options
author | NeilBrown <neilb@suse.de> | 2009-10-01 04:51:04 +0200 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2009-10-01 04:51:04 +0200 |
commit | 2b9aa337af7291d3f141322da96c9f667c99d53c (patch) | |
tree | 90c07f81f35050cd06ef57822fb6b3bb99947391 /mapfile.c | |
parent | Add missing space in "--detail --brief" output. (diff) | |
download | mdadm-2b9aa337af7291d3f141322da96c9f667c99d53c.tar.xz mdadm-2b9aa337af7291d3f141322da96c9f667c99d53c.zip |
Fix null-dereference in set_member_info
set_member_info would try to dereference ->metadata_version, without
checking that it isn't NULL.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'mapfile.c')
-rw-r--r-- | mapfile.c | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -303,19 +303,22 @@ struct map_ent *map_by_name(struct map_ent **map, char *name) */ static void set_member_info(struct supertype *st, struct mdstat_ent *ent) { - char version[strlen(ent->metadata_version)+1]; st->subarray[0] = '\0'; - if (strncmp(ent->metadata_version, "external:", 9) != 0) + if (ent->metadata_version == NULL || + strncmp(ent->metadata_version, "external:", 9) != 0) return; - strcpy(version, ent->metadata_version); - - if (is_subarray(&version[9])) { - char *subarray = strrchr(version, '/'); + if (is_subarray(&ent->metadata_version[9])) { + char version[strlen(ent->metadata_version)+1]; + char *subarray; char *name = &version[10]; + strcpy(version, ent->metadata_version); + subarray = strrchr(version, '/'); + name = &version[10]; + if (!subarray) return; *subarray++ = '\0'; |