From: Songpeng Li <songpeng.li@intel.com>
To: edk2-devel@lists.01.org
Cc: Fu Siyuan <siyuan.fu@intel.com>, Wu Jiaxin <jiaxin.wu@intel.com>
Subject: [PATCH] NetworkPkg: fix read memory access overflow in HTTPBoot.
Date: Tue, 25 Sep 2018 11:28:45 +0800 [thread overview]
Message-ID: <20180925032845.18836-1-songpeng.li@intel.com> (raw)
The input param String of AsciiStrStr() requires a pointer to
Null-terminated string, however in HttpTcpReceiveHeader() and
HttpUtilitiesParse(), the Buffersize before AllocateZeroPool()
is equal to the size of TCP header, after the CopyMem(), it
might not end with Null-terminator. It might cause memory
access overflow.
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1204
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Songpeng Li <songpeng.li@intel.com>
---
NetworkPkg/HttpDxe/HttpProto.c | 4 ++--
NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesProtocol.c | 4 +++-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/NetworkPkg/HttpDxe/HttpProto.c b/NetworkPkg/HttpDxe/HttpProto.c
index 94f89f5665..c729f76eff 100644
--- a/NetworkPkg/HttpDxe/HttpProto.c
+++ b/NetworkPkg/HttpDxe/HttpProto.c
@@ -1917,7 +1917,7 @@ HttpTcpReceiveHeader (
// Append the response string.
//
*BufferSize = *SizeofHeaders + Fragment.Len;
- Buffer = AllocateZeroPool (*BufferSize);
+ Buffer = AllocateZeroPool (*BufferSize + 1);
if (Buffer == NULL) {
Status = EFI_OUT_OF_RESOURCES;
return Status;
@@ -2016,7 +2016,7 @@ HttpTcpReceiveHeader (
// Append the response string.
//
*BufferSize = *SizeofHeaders + Fragment.Len;
- Buffer = AllocateZeroPool (*BufferSize);
+ Buffer = AllocateZeroPool (*BufferSize + 1);
if (Buffer == NULL) {
Status = EFI_OUT_OF_RESOURCES;
return Status;
diff --git a/NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesProtocol.c b/NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesProtocol.c
index a9a1c7c586..2292b52537 100644
--- a/NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesProtocol.c
+++ b/NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesProtocol.c
@@ -298,6 +298,7 @@ HttpUtilitiesParse (
CHAR8 *FieldName;
CHAR8 *FieldValue;
UINTN Index;
+ UINTN HttpBufferSize;
Status = EFI_SUCCESS;
TempHttpMessage = NULL;
@@ -311,7 +312,8 @@ HttpUtilitiesParse (
return EFI_INVALID_PARAMETER;
}
- TempHttpMessage = AllocateZeroPool (HttpMessageSize);
+ HttpBufferSize = HttpMessageSize + 1;
+ TempHttpMessage = AllocateZeroPool (HttpBufferSize);
if (TempHttpMessage == NULL) {
return EFI_OUT_OF_RESOURCES;
}
--
2.18.0.windows.1
next reply other threads:[~2018-09-25 3:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-25 3:28 Songpeng Li [this message]
2018-09-25 3:43 ` [PATCH] NetworkPkg: fix read memory access overflow in HTTPBoot Fu, Siyuan
2018-09-25 3:48 ` Wu, Jiaxin
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=20180925032845.18836-1-songpeng.li@intel.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