libpcap: Fix build when PACKAGECONFIG ipv6 is not enabled
[15.05/openwrt.git] / package / network / services / hostapd / patches / 012-EAP-pwd-server-Fix-last-fragment-length-validation.patch
1 From bef802ece03f9ae9d52a21f0cf4f1bc2c5a1f8aa Mon Sep 17 00:00:00 2001
2 From: Jouni Malinen <j@w1.fi>
3 Date: Sun, 1 Nov 2015 18:24:16 +0200
4 Subject: [PATCH] EAP-pwd server: Fix last fragment length validation
5
6 All but the last fragment had their length checked against the remaining
7 room in the reassembly buffer. This allowed a suitably constructed last
8 fragment frame to try to add extra data that would go beyond the buffer.
9 The length validation code in wpabuf_put_data() prevents an actual
10 buffer write overflow from occurring, but this results in process
11 termination. (CVE-2015-5314)
12
13 Signed-off-by: Jouni Malinen <j@w1.fi>
14 ---
15  src/eap_server/eap_server_pwd.c | 6 +++---
16  1 file changed, 3 insertions(+), 3 deletions(-)
17
18 diff --git a/src/eap_server/eap_server_pwd.c b/src/eap_server/eap_server_pwd.c
19 index cb83ff7..9f787ab 100644
20 --- a/src/eap_server/eap_server_pwd.c
21 +++ b/src/eap_server/eap_server_pwd.c
22 @@ -970,7 +970,7 @@ static void eap_pwd_process(struct eap_sm *sm, void *priv,
23         /*
24          * the first and all intermediate fragments have the M bit set
25          */
26 -       if (EAP_PWD_GET_MORE_BIT(lm_exch)) {
27 +       if (EAP_PWD_GET_MORE_BIT(lm_exch) || data->in_frag_pos) {
28                 if ((data->in_frag_pos + len) > wpabuf_size(data->inbuf)) {
29                         wpa_printf(MSG_DEBUG, "EAP-pwd: Buffer overflow "
30                                    "attack detected! (%d+%d > %d)",
31 @@ -981,6 +981,8 @@ static void eap_pwd_process(struct eap_sm *sm, void *priv,
32                 }
33                 wpabuf_put_data(data->inbuf, pos, len);
34                 data->in_frag_pos += len;
35 +       }
36 +       if (EAP_PWD_GET_MORE_BIT(lm_exch)) {
37                 wpa_printf(MSG_DEBUG, "EAP-pwd: Got a %d byte fragment",
38                            (int) len);
39                 return;
40 @@ -990,8 +992,6 @@ static void eap_pwd_process(struct eap_sm *sm, void *priv,
41          * buffering fragments so that's how we know it's the last)
42          */
43         if (data->in_frag_pos) {
44 -               wpabuf_put_data(data->inbuf, pos, len);
45 -               data->in_frag_pos += len;
46                 pos = wpabuf_head_u8(data->inbuf);
47                 len = data->in_frag_pos;
48                 wpa_printf(MSG_DEBUG, "EAP-pwd: Last fragment, %d bytes",
49 -- 
50 1.9.1
51