Date: Fri, 23 Jul 2021 14:19:53 GMT From: Eric van Gyzen <vangyzen@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: ea0e1b19f232 - main - aio_md_test: NUL-terminate result of readlink Message-ID: <202107231419.16NEJrOP074880@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by vangyzen: URL: https://cgit.FreeBSD.org/src/commit/?id=ea0e1b19f232331bffa75a0a64a6859c40f1cc4d commit ea0e1b19f232331bffa75a0a64a6859c40f1cc4d Author: Eric van Gyzen <vangyzen@FreeBSD.org> AuthorDate: 2021-07-23 13:49:55 +0000 Commit: Eric van Gyzen <vangyzen@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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202107231419.16NEJrOP074880>