connman.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
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


  parent reply	other threads:[~2022-08-01  8:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-01  8:00 [PATCH 1/6] wispr: Rename wispr_portal_list to wispr_portal_hash Daniel Wagner
2022-08-01  8:00 ` [PATCH 2/6] wispr: Ignore NULL proxy Daniel Wagner
2022-08-01  8:00 ` [PATCH 3/6] wispr: Add reference counter to portal context Daniel Wagner
2022-08-01  8:00 ` [PATCH 4/6] wispr: Update portal context references Daniel Wagner
2022-08-01  8:00 ` Daniel Wagner [this message]
2022-08-01  8:00 ` [PATCH 6/6] AUTHORS: Mention Nathan's contributions Daniel Wagner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220801080043.4861-5-wagi@monom.org \
    --to=wagi@monom.org \
    --cc=connman@lists.linux.dev \
    --cc=ncrandall@tesla.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).