From: Dan Williams Date: Sat, 14 Jun 2008 00:27:30 +0000 (-0700) Subject: ddf: fix 'ddf' pointer corruption X-Git-Tag: mdadm-3.0-devel1~159^2~12 X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fmdadm.git;a=commitdiff_plain;h=1ba6bff90226a609700b8e78345a41bbe1997845 ddf: fix 'ddf' pointer corruption hostname[17] = 0 overwrites the last byte of the ddf pointer Signed-off-by: Dan Williams --- diff --git a/super-ddf.c b/super-ddf.c index 2ec04a7f..0d2a4561 100644 --- a/super-ddf.c +++ b/super-ddf.c @@ -1561,8 +1561,8 @@ static int init_super_ddf(struct supertype *st, * Remaining 16 are serial number.... maybe a hostname would do? */ memcpy(ddf->controller.guid, T10, sizeof(T10)); - gethostname(hostname, 17); - hostname[17] = 0; + gethostname(hostname, sizeof(hostname)); + hostname[sizeof(hostname) - 1] = 0; hostlen = strlen(hostname); memcpy(ddf->controller.guid + 24 - hostlen, hostname, hostlen); for (i = strlen(T10) ; i+hostlen < 24; i++)