Skip to content

Commit 21d702a

Browse files
guyharrisinfrastation
authored andcommitted
CVE-2017-11541: In safeputs(), check the length before checking for a NUL terminator.
safeputs() doesn't do packet bounds checking of its own; it assumes that the caller has checked the availability in the packet data of all maxlen bytes of data. This means we should check that we're within the specified limit before looking at the byte. This fixes a buffer over-read discovered by Kamil Frankowicz. Add a test using the capture file supplied by the reporter(s).
1 parent bed4806 commit 21d702a

File tree

4 files changed

+4
-1
lines changed

4 files changed

+4
-1
lines changed

tests/TESTLIST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ isoclns-heapoverflow-2 isoclns-heapoverflow-2.pcap isoclns-heapoverflow-2.out -e
440440
isoclns-heapoverflow-3 isoclns-heapoverflow-3.pcap isoclns-heapoverflow-3.out -e -c1
441441
stp-v4-length-sigsegv stp-v4-length-sigsegv.pcap stp-v4-length-sigsegv.out
442442
hoobr_pimv1 hoobr_pimv1.pcap hoobr_pimv1.out
443+
hoobr_safeputs hoobr_safeputs.pcap hoobr_safeputs.out
443444

444445
# RTP tests
445446
# fuzzed pcap

tests/hoobr_safeputs.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
LLDP, length 808464418: 0000000000
2+
[|LLDP]

tests/hoobr_safeputs.pcap

88 Bytes
Binary file not shown.

util-print.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ safeputs(netdissect_options *ndo,
904904
{
905905
u_int idx = 0;
906906

907-
while (*s && idx < maxlen) {
907+
while (idx < maxlen && *s) {
908908
safeputchar(ndo, *s);
909909
idx++;
910910
s++;

0 commit comments

Comments
 (0)