b98e1832445e764af8686151e4745356f83fbedf
[openwrt/openwrt.git] /
1 From fe76f487e28bdc61940f304f153a954cf36935ea Mon Sep 17 00:00:00 2001
2 From: Jouni Malinen <jouni@codeaurora.org>
3 Date: Wed, 17 Apr 2019 01:55:32 +0300
4 Subject: [PATCH 1/3] EAP-pwd server: Fix reassembly buffer handling
5
6 data->inbuf allocation might fail and if that were to happen, the next
7 fragment in the exchange could have resulted in NULL pointer
8 dereference. Unexpected fragment with more bit might also be able to
9 trigger this. Fix that by explicitly checking for data->inbuf to be
10 available before using it.
11
12 Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
13 ---
14 src/eap_server/eap_server_pwd.c | 8 +++++++-
15 1 file changed, 7 insertions(+), 1 deletion(-)
16
17 --- a/src/eap_server/eap_server_pwd.c
18 +++ b/src/eap_server/eap_server_pwd.c
19 @@ -947,6 +947,12 @@ static void eap_pwd_process(struct eap_s
20 * the first and all intermediate fragments have the M bit set
21 */
22 if (EAP_PWD_GET_MORE_BIT(lm_exch) || data->in_frag_pos) {
23 + if (!data->inbuf) {
24 + wpa_printf(MSG_DEBUG,
25 + "EAP-pwd: No buffer for reassembly");
26 + eap_pwd_state(data, FAILURE);
27 + return;
28 + }
29 if ((data->in_frag_pos + len) > wpabuf_size(data->inbuf)) {
30 wpa_printf(MSG_DEBUG, "EAP-pwd: Buffer overflow "
31 "attack detected! (%d+%d > %d)",
32 @@ -967,7 +973,7 @@ static void eap_pwd_process(struct eap_s
33 * last fragment won't have the M bit set (but we're obviously
34 * buffering fragments so that's how we know it's the last)
35 */
36 - if (data->in_frag_pos) {
37 + if (data->in_frag_pos && data->inbuf) {
38 pos = wpabuf_head_u8(data->inbuf);
39 len = data->in_frag_pos;
40 wpa_printf(MSG_DEBUG, "EAP-pwd: Last fragment, %d bytes",