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

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. 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 <jouni@codeaurora.org>
  10. ---
  11. src/eap_peer/eap_pwd.c | 9 ++++++++-
  12. 1 file changed, 8 insertions(+), 1 deletion(-)
  13. diff --git a/src/eap_peer/eap_pwd.c b/src/eap_peer/eap_pwd.c
  14. index 46894a5..76fcad4 100644
  15. --- a/src/eap_peer/eap_pwd.c
  16. +++ b/src/eap_peer/eap_pwd.c
  17. @@ -932,6 +932,13 @@ eap_pwd_process(struct eap_sm *sm, void *priv, struct eap_method_ret *ret,
  18. * buffer and ACK the fragment
  19. */
  20. if (EAP_PWD_GET_MORE_BIT(lm_exch) || data->in_frag_pos) {
  21. + if (!data->inbuf) {
  22. + wpa_printf(MSG_DEBUG,
  23. + "EAP-pwd: No buffer for reassembly");
  24. + ret->methodState = METHOD_DONE;
  25. + ret->decision = DECISION_FAIL;
  26. + return NULL;
  27. + }
  28. data->in_frag_pos += len;
  29. if (data->in_frag_pos > wpabuf_size(data->inbuf)) {
  30. wpa_printf(MSG_INFO, "EAP-pwd: Buffer overflow attack "
  31. @@ -958,7 +965,7 @@ eap_pwd_process(struct eap_sm *sm, void *priv, struct eap_method_ret *ret,
  32. /*
  33. * we're buffering and this is the last fragment
  34. */
  35. - if (data->in_frag_pos) {
  36. + if (data->in_frag_pos && data->inbuf) {
  37. wpa_printf(MSG_DEBUG, "EAP-pwd: Last fragment, %d bytes",
  38. (int) len);
  39. pos = wpabuf_head_u8(data->inbuf);
  40. --
  41. 2.7.4