aio_md_test: NUL-terminate result of readlink
readlink does not NUL-terminate the output buffer. This led to spurious failures to destroy the md device because the unit number was garbage. NUL-terminate the output buffer. Reported by: ASLR MFC after: 1 week Sponsored by: Dell EMC Isilon
This commit is contained in:
parent
c6f92e64b6
commit
ea0e1b19f2
@ -767,8 +767,9 @@ aio_md_cleanup(void)
|
||||
strerror(errno));
|
||||
return;
|
||||
}
|
||||
n = readlink(MDUNIT_LINK, buf, sizeof(buf));
|
||||
n = readlink(MDUNIT_LINK, buf, sizeof(buf) - 1);
|
||||
if (n > 0) {
|
||||
buf[n] = '\0';
|
||||
if (sscanf(buf, "%d", &unit) == 1 && unit >= 0) {
|
||||
bzero(&mdio, sizeof(mdio));
|
||||
mdio.md_version = MDIOVERSION;
|
||||
|
Loading…
Reference in New Issue
Block a user