Sophie

Sophie

distrib > Mageia > 8 > i586 > by-pkgid > bbe85caa080961fd4c431b9d5cf58ef8 > files > 8

connman-1.38-2.3.mga8.src.rpm

From: Daniel Wagner <wagi@monom.org>
To: connman@lists.linux.dev
Cc: Nathan Crandall <ncrandall@tesla.com>
Subject: [PATCH 5/6] gweb: Fix OOB write in received_data()
Date: Mon,  1 Aug 2022 10:00:42 +0200	[thread overview]
Message-ID: <20220801080043.4861-5-wagi@monom.org> (raw)
In-Reply-To: <20220801080043.4861-1-wagi@monom.org>

From: Nathan Crandall <ncrandall@tesla.com>

There is a mismatch of handling binary vs. C-string data with memchr
and strlen, resulting in pos, count, and bytes_read to become out of
sync and result in a heap overflow.  Instead, do not treat the buffer
as an ASCII C-string. We calculate the count based on the return value
of memchr, instead of strlen.

Fixes: CVE-2022-32292
---
 gweb/gweb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gweb/gweb.c b/gweb/gweb.c
index 12fcb1d8ab32..13c6c5f25102 100644
--- a/gweb/gweb.c
+++ b/gweb/gweb.c
@@ -918,7 +918,7 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond,
 		}
 
 		*pos = '\0';
-		count = strlen((char *) ptr);
+		count = pos - ptr;
 		if (count > 0 && ptr[count - 1] == '\r') {
 			ptr[--count] = '\0';
 			bytes_read--;
-- 
2.37.1