All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] eap-pwd: add length checks for fragmented packets
@ 2022-01-19 18:13 James Prestwood
  0 siblings, 0 replies; 2+ messages in thread
From: James Prestwood @ 2022-01-19 18:13 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 1146 bytes --]

---
 src/eap-pwd.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/eap-pwd.c b/src/eap-pwd.c
index af373493..cd6684e7 100644
--- a/src/eap-pwd.c
+++ b/src/eap-pwd.c
@@ -669,6 +669,14 @@ static void eap_pwd_handle_request(struct eap_state *eap,
 
 		/* remove length of Total-Length parameter (2) */
 		pwd->rx_frag_total = l_get_be16(pkt + 1) - 2;
+
+		if (pwd->rx_frag_total < len - 2) {
+			l_error("Total-Length too small for remaining length");
+			pwd->rx_frag_total = 0;
+
+			return;
+		}
+
 		pwd->rx_frag_buf = l_malloc(pwd->rx_frag_total);
 
 		/* skip copying Total-Length for easier processing later */
@@ -687,6 +695,12 @@ static void eap_pwd_handle_request(struct eap_state *eap,
 
 	/* more rx fragments */
 	if (pwd->rx_frag_buf) {
+		if (pwd->rx_frag_total - pwd->rx_frag_count <
+						(uint16_t) len - 1) {
+			l_error("Not enough room for fragment (%zu)", len - 1);
+			return;
+
+		}
 		/* continue building packet (not including PWD-Exch byte) */
 		memcpy(pwd->rx_frag_buf + pwd->rx_frag_count, pkt + 1, len - 1);
 		pwd->rx_frag_count += (len - 1);
-- 
2.31.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] eap-pwd: add length checks for fragmented packets
@ 2022-01-20 19:51 Denis Kenzior
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2022-01-20 19:51 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 183 bytes --]

Hi James,

On 1/19/22 12:13, James Prestwood wrote:
> ---
>   src/eap-pwd.c | 14 ++++++++++++++
>   1 file changed, 14 insertions(+)
> 

Applied, thanks.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-01-20 19:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-19 18:13 [PATCH] eap-pwd: add length checks for fragmented packets James Prestwood
2022-01-20 19:51 Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.