]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
ddf: fix 'ddf' pointer corruption
authorDan Williams <dan.j.williams@intel.com>
Sat, 14 Jun 2008 00:27:30 +0000 (17:27 -0700)
committerDan Williams <dan.j.williams@intel.com>
Sat, 14 Jun 2008 00:27:30 +0000 (17:27 -0700)
hostname[17] = 0 overwrites the last byte of the ddf pointer

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
super-ddf.c

index 2ec04a7f042a969841dbce61293c813bf68967df..0d2a45617ca52c8ce494645c3d297d56fceae632 100644 (file)
@@ -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++)