065-0003-EAP-pwd-peer-Fix-reassembly-buffer-handling.patch 1.4 KB

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