Date: Tue, 18 May 2021 03:08:17 GMT From: Colin Percival <cperciva@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 330f110bf1e4 - main - Fix 'hostuuid: preload data malformed' warning Message-ID: <202105180308.14I38Hil021352@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=330f110bf1e420dc8d8ddadc4030e0ae1f1c52bd commit 330f110bf1e420dc8d8ddadc4030e0ae1f1c52bd Author: Colin Percival <cperciva@FreeBSD.org> AuthorDate: 2021-05-15 05:57:38 +0000 Commit: Colin Percival <cperciva@FreeBSD.org> CommitDate: 2021-05-18 03:07:49 +0000 Fix 'hostuuid: preload data malformed' warning If the preloaded hostuuid value is invalid and verbose booting is enabled, a warning is printed. This printf had two bugs: 1. It was missing a trailing \n character. 2. The malformed UUID is printed with %s even though it is not known to be NUL-terminated. This commit adds the missing \n and uses %.*s with the (already known) length of the preloaded UUID to ensure that we don't read past the end of the buffer. Reported by: kevans Fixes: c3188289 Preload hostuuid for early-boot use MFC after: 3 days --- sys/kern/kern_jail.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c index b5c8f6ebf9be..f4cd6bd38d35 100644 --- a/sys/kern/kern_jail.c +++ b/sys/kern/kern_jail.c @@ -263,8 +263,8 @@ prison0_init(void) (void)strlcpy(prison0.pr_hostuuid, data, size + 1); } else if (bootverbose) { - printf("hostuuid: preload data malformed: '%s'", - data); + printf("hostuuid: preload data malformed: '%.*s'\n", + (int)size, data); } } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105180308.14I38Hil021352>