ddf: fix 'ddf' pointer corruption
hostname[17] = 0 overwrites the last byte of the ddf pointer Signed-off-by: Dan Williams <dan.j.williams@intel.com>
This commit is contained in:
parent
56aca704a5
commit
1ba6bff902
|
@ -1561,8 +1561,8 @@ static int init_super_ddf(struct supertype *st,
|
||||||
* Remaining 16 are serial number.... maybe a hostname would do?
|
* Remaining 16 are serial number.... maybe a hostname would do?
|
||||||
*/
|
*/
|
||||||
memcpy(ddf->controller.guid, T10, sizeof(T10));
|
memcpy(ddf->controller.guid, T10, sizeof(T10));
|
||||||
gethostname(hostname, 17);
|
gethostname(hostname, sizeof(hostname));
|
||||||
hostname[17] = 0;
|
hostname[sizeof(hostname) - 1] = 0;
|
||||||
hostlen = strlen(hostname);
|
hostlen = strlen(hostname);
|
||||||
memcpy(ddf->controller.guid + 24 - hostlen, hostname, hostlen);
|
memcpy(ddf->controller.guid + 24 - hostlen, hostname, hostlen);
|
||||||
for (i = strlen(T10) ; i+hostlen < 24; i++)
|
for (i = strlen(T10) ; i+hostlen < 24; i++)
|
||||||
|
|
Loading…
Reference in New Issue