git: ac20fa249f12 - stable/13 - aio_md_test: NUL-terminate result of readlink
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 02 Mar 2022 21:57:19 UTC
The branch stable/13 has been updated by vangyzen: URL: https://cgit.FreeBSD.org/src/commit/?id=ac20fa249f129b5c1eb65d378baf4f954dd03bc9 commit ac20fa249f129b5c1eb65d378baf4f954dd03bc9 Author: Eric van Gyzen <vangyzen@FreeBSD.org> AuthorDate: 2021-07-23 13:49:55 +0000 Commit: Eric van Gyzen <vangyzen@FreeBSD.org> CommitDate: 2022-03-02 21:56:30 +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 (cherry picked from commit ea0e1b19f232331bffa75a0a64a6859c40f1cc4d) --- 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 af2e3823d1ff..0f929c510e9f 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;