Page MenuHomeFreeBSD

D54623.diff
No OneTemporary

D54623.diff

diff --git a/lib/libutil/tests/trimdomain_test.c b/lib/libutil/tests/trimdomain_test.c
--- a/lib/libutil/tests/trimdomain_test.c
+++ b/lib/libutil/tests/trimdomain_test.c
@@ -78,11 +78,13 @@
main(void)
{
- printf("1..5\n");
+ printf("1..6\n");
testit(TESTFQDN, -1, TESTHOST, "self");
testit("XXX" TESTDOMAIN, -1, "XXX", "different host, same domain");
testit("XXX" TESTDOMAIN, 1, NULL, "short hostsize");
+ testit("XXX" TESTDOMAIN, strlen(TESTDOMAIN) + 256, "XXX",
+ "long hostsize");
testit("bogus.example.net", -1, NULL, "arbitrary host");
testit("XXX." TESTFQDN, -1, NULL, "domain is local hostname");
diff --git a/lib/libutil/trimdomain.c b/lib/libutil/trimdomain.c
--- a/lib/libutil/trimdomain.c
+++ b/lib/libutil/trimdomain.c
@@ -73,6 +73,12 @@
if (domain[0] == '\0')
return;
+ /*
+ * Clamp hostsize down if it's out-of-bounds of fullhost, to avoid any
+ * kind of out-of-bounds read in the below memchr().
+ */
+ hostsize = strnlen(fullhost, hostsize);
+
s = fullhost;
end = s + hostsize + 1;
if ((s = memchr(s, '.', (size_t)(end - s))) != NULL) {

File Metadata

Mime Type
text/plain
Expires
Thu, Jul 16, 7:02 AM (11 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35128060
Default Alt Text
D54623.diff (1 KB)

Event Timeline