Skip to content

Commit 7039327

Browse files
guyharrisinfrastation
authored andcommitted
CVE-2017-11543/Make sure the SLIP direction octet is valid.
Report if it's not, and don't use it as an out-of-bounds index into an array. This fixes a buffer overflow discovered by Wilfried Kirsch. Add a test using the capture file supplied by the reporter(s), modified so the capture file won't be rejected as an invalid capture.
1 parent 21d702a commit 7039327

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

print-sl.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,21 @@ sliplink_print(netdissect_options *ndo,
131131
u_int hlen;
132132

133133
dir = p[SLX_DIR];
134-
ND_PRINT((ndo, dir == SLIPDIR_IN ? "I " : "O "));
134+
switch (dir) {
135135

136+
case SLIPDIR_IN:
137+
ND_PRINT((ndo, "I "));
138+
break;
139+
140+
case SLIPDIR_OUT:
141+
ND_PRINT((ndo, "O "));
142+
break;
143+
144+
default:
145+
ND_PRINT((ndo, "Invalid direction %d ", dir));
146+
dir = -1;
147+
break;
148+
}
136149
if (ndo->ndo_nflag) {
137150
/* XXX just dump the header */
138151
register int i;
@@ -155,13 +168,21 @@ sliplink_print(netdissect_options *ndo,
155168
* has restored the IP header copy to IPPROTO_TCP.
156169
*/
157170
lastconn = ((const struct ip *)&p[SLX_CHDR])->ip_p;
171+
ND_PRINT((ndo, "utcp %d: ", lastconn));
172+
if (dir == -1) {
173+
/* Direction is bogus, don't use it */
174+
return;
175+
}
158176
hlen = IP_HL(ip);
159177
hlen += TH_OFF((const struct tcphdr *)&((const int *)ip)[hlen]);
160178
lastlen[dir][lastconn] = length - (hlen << 2);
161-
ND_PRINT((ndo, "utcp %d: ", lastconn));
162179
break;
163180

164181
default:
182+
if (dir == -1) {
183+
/* Direction is bogus, don't use it */
184+
return;
185+
}
165186
if (p[SLX_CHDR] & TYPE_COMPRESSED_TCP) {
166187
compressed_sl_print(ndo, &p[SLX_CHDR], ip,
167188
length, dir);

tests/TESTLIST

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,9 @@ stp-v4-length-sigsegv stp-v4-length-sigsegv.pcap stp-v4-length-sigsegv.out
442442
hoobr_pimv1 hoobr_pimv1.pcap hoobr_pimv1.out
443443
hoobr_safeputs hoobr_safeputs.pcap hoobr_safeputs.out
444444

445+
# bad packets from Wilfried Kirsch
446+
slip-bad-direction slip-bad-direction.pcap slip-bad-direction.out -ve
447+
445448
# RTP tests
446449
# fuzzed pcap
447450
rtp-seg-fault-1 rtp-seg-fault-1.pcap rtp-seg-fault-1.out -v -T rtp

tests/slip-bad-direction.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Invalid direction 231 e7.e7.e7.e7.e7.e7.e7.e7.e7.e7.e7.e7.e7.e7.e7: ip v14

tests/slip-bad-direction.pcap

79 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)