cc805625862ea5384f69f9b6de2b98caf78d98e8
[openwrt/staging/rmilecki.git] / package / network / services / hostapd / patches / 065-0003-EAP-pwd-peer-Fix-reassembly-buffer-handling.patch
1 From d2d1a324ce937628e4d9d9999fe113819b7d4478 Mon Sep 17 00:00:00 2001
2 From: Jouni Malinen <jouni@codeaurora.org>
3 Date: Wed, 17 Apr 2019 02:21:20 +0300
4 Subject: [PATCH 3/3] EAP-pwd peer: Fix reassembly buffer handling
5
6 Unexpected fragment might result in data->inbuf not being allocated
7 before processing and that could have resulted in NULL pointer
8 dereference. Fix that by explicitly checking for data->inbuf to be
9 available before using it.
10
11 Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
12 ---
13 src/eap_peer/eap_pwd.c | 9 ++++++++-
14 1 file changed, 8 insertions(+), 1 deletion(-)
15
16 --- a/src/eap_peer/eap_pwd.c
17 +++ b/src/eap_peer/eap_pwd.c
18 @@ -969,6 +969,13 @@ eap_pwd_process(struct eap_sm *sm, void
19 * buffer and ACK the fragment
20 */
21 if (EAP_PWD_GET_MORE_BIT(lm_exch) || data->in_frag_pos) {
22 + if (!data->inbuf) {
23 + wpa_printf(MSG_DEBUG,
24 + "EAP-pwd: No buffer for reassembly");
25 + ret->methodState = METHOD_DONE;
26 + ret->decision = DECISION_FAIL;
27 + return NULL;
28 + }
29 data->in_frag_pos += len;
30 if (data->in_frag_pos > wpabuf_size(data->inbuf)) {
31 wpa_printf(MSG_INFO, "EAP-pwd: Buffer overflow attack "
32 @@ -995,7 +1002,7 @@ eap_pwd_process(struct eap_sm *sm, void
33 /*
34 * we're buffering and this is the last fragment
35 */
36 - if (data->in_frag_pos) {
37 + if (data->in_frag_pos && data->inbuf) {
38 wpa_printf(MSG_DEBUG, "EAP-pwd: Last fragment, %d bytes",
39 (int) len);
40 pos = wpabuf_head_u8(data->inbuf);