From: NeilBrown Date: Fri, 25 Sep 2009 07:56:22 +0000 (+1000) Subject: super0: fix crash on assemble if homehost is not set. X-Git-Tag: mdadm-3.0.2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=40d28f0d1bf28bc706b734932f46a9190b9fec5b;p=thirdparty%2Fmdadm.git super0: fix crash on assemble if homehost is not set. If homehost is not set - typically during early boot, and assemble of v0.90 metadata arrays will crash. Reported-by: Paweł Sikora Signed-off-by: NeilBrown --- diff --git a/super0.c b/super0.c index 2b4942f4..07f47924 100644 --- a/super0.c +++ b/super0.c @@ -305,9 +305,13 @@ static int match_home0(struct supertype *st, char *homehost) { mdp_super_t *sb = st->sb; char buf[20]; - char *hash = sha1_buffer(homehost, - strlen(homehost), - buf); + char *hash; + + if (!homehost) + return 0; + hash = sha1_buffer(homehost, + strlen(homehost), + buf); return (memcmp(&sb->set_uuid2, hash, 8)==0); }