public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Chang, Abner" <abner.chang@amd.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	"houjingyi647@gmail.com" <houjingyi647@gmail.com>
Subject: Re: [edk2-devel] [PATCH] RedfishPkg/RedfishLib: Avoid possible overflow in memcpy
Date: Fri, 27 Jan 2023 04:05:59 +0000	[thread overview]
Message-ID: <MN2PR12MB3966A20E511853EA1B6C4CC0EACC9@MN2PR12MB3966.namprd12.prod.outlook.com> (raw)
In-Reply-To: <CAN1eSkuRgusN=ozdcKrxQG5UNUeWcZ1=z_wZJ93=3u+vdjrvkg@mail.gmail.com>

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

[AMD Official Use Only - General]

Hi houjingyi,
May I know why there are two messages with the same subject? Are these two identical?
Thanks
Abner
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of houjingyi via groups.io
Sent: Wednesday, January 25, 2023 10:23 PM
To: devel@edk2.groups.io
Subject: [edk2-devel] [PATCH] RedfishPkg/RedfishLib: Avoid possible overflow in memcpy

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

>From 0541928e66eb01802a855bbbae125ef0b02259d6 Mon Sep 17 00:00:00 2001
From: houjingyi233 <houjingyi647@gmail.com<mailto:houjingyi647@gmail.com>>
Date: Wed, 25 Jan 2023 22:11:31 +0800
Subject: [PATCH] RedfishPkg/RedfishLib: Avoid possible overflow in memcpy

It is possible that when the third argument of the memcpy is unequal
to the first argument of malloc will cause overflow, when +1 in malloc
cause int overflow malloc a very small size of memory and followed memcpy
will cause heap overflow.

Signed-off-by: houjingyi233 <houjingyi647@gmail.com<mailto:houjingyi647@gmail.com>>
---
 .../RedfishLib/edk2libredfish/src/redpath.c           | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/redpath.c b/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/redpath.c
index cf5ab85165..a1523938f7 100644
--- a/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/redpath.c
+++ b/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/redpath.c
@@ -175,6 +175,10 @@ parseNode (
     return;
   }

+  if ((opChars - index)+1 < opChars - index) {
+    return;
+  }
+
   node->next->propName = (char *)malloc ((opChars - index)+1);
   memcpy (node->next->propName, index, (opChars - index));
   node->next->propName[(opChars - index)] = 0;
@@ -189,6 +193,9 @@ parseNode (
     break;
   }

+  if (tmpIndex+1 < tmpIndex) {
+    return;
+  }
   node->next->op = (char *)malloc (tmpIndex+1);
   memcpy (node->next->op, opChars, tmpIndex);
   node->next->op[tmpIndex] = 0;
@@ -217,6 +224,10 @@ getStringTill (
     return strdup (string);
   }

+  if ((end-string)+1 < end-string) {
+    return;
+  }
+
   ret = (char *)malloc ((end-string)+1);
   memcpy (ret, string, (end-string));
   ret[(end-string)] = 0;
--
2.37.3


[-- Attachment #2: Type: text/html, Size: 6533 bytes --]

  parent reply	other threads:[~2023-01-27  4:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-25 14:23 [PATCH] RedfishPkg/RedfishLib: Avoid possible overflow in memcpy houjingyi
2023-01-25 14:30 ` houjingyi647
2023-01-27  4:05 ` Chang, Abner [this message]
2023-01-27  7:27   ` [edk2-devel] " houjingyi

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-list 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=MN2PR12MB3966A20E511853EA1B6C4CC0EACC9@MN2PR12MB3966.namprd12.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /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