libpcap: Fix build when PACKAGECONFIG ipv6 is not enabled
[15.05/openwrt.git] / package / network / services / hostapd / patches / 003-WPS-Fix-HTTP-chunked-transfer-encoding-parser.patch
1 From 5acd23f4581da58683f3cf5e36cb71bbe4070bd7 Mon Sep 17 00:00:00 2001
2 From: Jouni Malinen <j@w1.fi>
3 Date: Tue, 28 Apr 2015 17:08:33 +0300
4 Subject: [PATCH] WPS: Fix HTTP chunked transfer encoding parser
5
6 strtoul() return value may end up overflowing the int h->chunk_size and
7 resulting in a negative value to be stored as the chunk_size. This could
8 result in the following memcpy operation using a very large length
9 argument which would result in a buffer overflow and segmentation fault.
10
11 This could have been used to cause a denial service by any device that
12 has been authorized for network access (either wireless or wired). This
13 would affect both the WPS UPnP functionality in a WPS AP (hostapd with
14 upnp_iface parameter set in the configuration) and WPS ER
15 (wpa_supplicant with WPS_ER_START control interface command used).
16
17 Validate the parsed chunk length value to avoid this. In addition to
18 rejecting negative values, we can also reject chunk size that would be
19 larger than the maximum configured body length.
20
21 Thanks to Kostya Kortchinsky of Google security team for discovering and
22 reporting this issue.
23
24 Signed-off-by: Jouni Malinen <j@w1.fi>
25 ---
26  src/wps/httpread.c | 7 +++++++
27  1 file changed, 7 insertions(+)
28
29 diff --git a/src/wps/httpread.c b/src/wps/httpread.c
30 index 2f08f37..d2855e3 100644
31 --- a/src/wps/httpread.c
32 +++ b/src/wps/httpread.c
33 @@ -533,6 +533,13 @@ static void httpread_read_handler(int sd, void *eloop_ctx, void *sock_ctx)
34                                         if (!isxdigit(*cbp))
35                                                 goto bad;
36                                         h->chunk_size = strtoul(cbp, NULL, 16);
37 +                                       if (h->chunk_size < 0 ||
38 +                                           h->chunk_size > h->max_bytes) {
39 +                                               wpa_printf(MSG_DEBUG,
40 +                                                          "httpread: Invalid chunk size %d",
41 +                                                          h->chunk_size);
42 +                                               goto bad;
43 +                                       }
44                                         /* throw away chunk header
45                                          * so we have only real data
46                                          */
47 -- 
48 1.9.1
49