Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F162634111
D54623.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D54623.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D54623: libutil: avoid an out-of-bounds read in trimdomain(3)
Attached
Detach File
Event Timeline
Log In to Comment