git: 330f110bf1e4 - main - Fix 'hostuuid: preload data malformed' warning
Colin Percival
cperciva at FreeBSD.org
Tue May 18 03:08:17 UTC 2021
The branch main has been updated by cperciva:
URL: https://cgit.FreeBSD.org/src/commit/?id=330f110bf1e420dc8d8ddadc4030e0ae1f1c52bd
commit 330f110bf1e420dc8d8ddadc4030e0ae1f1c52bd
Author: Colin Percival <cperciva at FreeBSD.org>
AuthorDate: 2021-05-15 05:57:38 +0000
Commit: Colin Percival <cperciva at 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);
}
}
}
More information about the dev-commits-src-all
mailing list