Page MenuHomeFreeBSD

h_resolv: Fix a buffer overflow in load().
ClosedPublic

Authored by jhb on Dec 27 2022, 10:25 PM.
Tags
None
Referenced Files
F150531818: D37886.id.diff
Thu, Apr 2, 2:35 AM
Unknown Object (File)
Wed, Apr 1, 7:29 PM
Unknown Object (File)
Tue, Mar 17, 7:47 AM
Unknown Object (File)
Thu, Mar 12, 8:28 PM
Unknown Object (File)
Sun, Mar 8, 6:17 PM
Unknown Object (File)
Sun, Mar 8, 9:38 AM
Unknown Object (File)
Feb 8 2026, 1:12 PM
Unknown Object (File)
Feb 7 2026, 11:40 PM
Subscribers

Details

Summary

fgetln() returns a pointer to an array of characters that is 'len'
characters long, not 'len + 1'. While here, overwriting the contents
of the buffer returned by fgetln isn't really safe, so switch to using
getline() instead.

Note that these fixes are a subset of those applied to a
near-identical copy of this function in libc's resolv_test.c in commit
2afeaad315ac19450389b8f2befdbe7c91c37818.

Reported by: CHERI (buffer overflow)

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable