ConnMan network manager
 help / color / mirror / Atom feed
From: Colin Wee <cwee@tesla.com>
To: "connman@lists.linux.dev" <connman@lists.linux.dev>
Cc: Marcel Holtmann <marcel@holtmann.org>
Subject: [PATCH] Prevent a short allocation by checking upper_length
Date: Fri, 3 May 2024 21:58:44 +0000	[thread overview]
Message-ID: <lvq5tor4tudvh4xtxy47p3cescldr3v5c3fijgrqwkdfrktq5g@ycqxblnjgbaj> (raw)

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

Hey Connman Maintainers,

I'd like to submit a patch fixing potential memory corruption in
connman. I've attached it for review, please let me know what you think.

-Colin

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Prevent-a-short-allocation-by-checking-upper_length.patch --]
[-- Type: text/x-patch; name="0001-Prevent-a-short-allocation-by-checking-upper_length.patch", Size: 759 bytes --]

From c9452e34e45be8b54fac0996464f4a5487799377 Mon Sep 17 00:00:00 2001
From: Tesla OpenSource <opensource@tesla.com>
Date: Fri, 3 May 2024 14:50:22 -0700
Subject: [PATCH] Prevent a short allocation by checking upper_length

---
 gdhcp/client.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gdhcp/client.c b/gdhcp/client.c
index 2afa19e6..c9234a18 100644
--- a/gdhcp/client.c
+++ b/gdhcp/client.c
@@ -1863,6 +1863,8 @@ static char *malloc_option_value_string(uint8_t *option, GDHCPOptionType type)
 		return NULL;
 	upper_length = len_of_option_as_string[type] *
 			((unsigned)len / (unsigned)optlen);
+	if (upper_length == 0)
+		return NULL;
 	dest = ret = g_malloc(upper_length + 1);
 	if (!ret)
 		return NULL;
-- 
2.45.0


             reply	other threads:[~2024-05-03 21:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-03 21:58 Colin Wee [this message]
2024-05-08 15:47 ` [PATCH] Prevent a short allocation by checking upper_length Marcel Holtmann
2024-05-10 23:41   ` Colin Wee
2024-05-10 23:51   ` Colin Wee
2024-05-10 23:53   ` Colin Wee
2024-05-10 23:53     ` [PATCH] Prevent a short allocation by checking upper_length Colin Wee
2024-05-24 21:30       ` Colin Wee
2024-05-28 15:45       ` Denis Kenzior
2024-05-28 16:08       ` patchwork-bot+connman

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=lvq5tor4tudvh4xtxy47p3cescldr3v5c3fijgrqwkdfrktq5g@ycqxblnjgbaj \
    --to=cwee@tesla.com \
    --cc=connman@lists.linux.dev \
    --cc=marcel@holtmann.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).