git: ea0e1b19f232 - main - aio_md_test: NUL-terminate result of readlink
Eric van Gyzen
vangyzen at FreeBSD.org
Fri Jul 23 14:19:54 UTC 2021
The branch main has been updated by vangyzen:
URL: https://cgit.FreeBSD.org/src/commit/?id=ea0e1b19f232331bffa75a0a64a6859c40f1cc4d
commit ea0e1b19f232331bffa75a0a64a6859c40f1cc4d
Author: Eric van Gyzen <vangyzen at FreeBSD.org>
AuthorDate: 2021-07-23 13:49:55 +0000
Commit: Eric van Gyzen <vangyzen at FreeBSD.org>
CommitDate: 2021-07-23 14:19:29 +0000
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
---
tests/sys/aio/aio_test.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/sys/aio/aio_test.c b/tests/sys/aio/aio_test.c
index 4b0fb5f7892b..00b0f430529f 100644
--- a/tests/sys/aio/aio_test.c
+++ b/tests/sys/aio/aio_test.c
@@ -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;
More information about the dev-commits-src-all
mailing list