* [PATCH 0/2] fix read memory access overflow in HTTPBoot.
@ 2018-09-25 8:24 Songpeng Li
2018-09-25 8:24 ` [PATCH 1/2] NetworkPkg/HttpDxe: " Songpeng Li
2018-09-25 8:24 ` [PATCH 2/2] NetworkPkg/HttpUtilitiesDxe: fix read memory access overflow Songpeng Li
0 siblings, 2 replies; 4+ messages in thread
From: Songpeng Li @ 2018-09-25 8:24 UTC (permalink / raw)
To: edk2-devel
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.
Songpeng Li (2):
NetworkPkg/HttpDxe: fix read memory access overflow in HTTPBoot.
NetworkPkg/HttpUtilitiesDxe: fix read memory access overflow.
NetworkPkg/HttpDxe/HttpProto.c | 10 ++++++----
NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesProtocol.c | 8 +++++++-
2 files changed, 13 insertions(+), 5 deletions(-)
--
2.18.0.windows.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] NetworkPkg/HttpDxe: fix read memory access overflow in HTTPBoot.
2018-09-25 8:24 [PATCH 0/2] fix read memory access overflow in HTTPBoot Songpeng Li
@ 2018-09-25 8:24 ` Songpeng Li
2018-09-25 8:24 ` [PATCH 2/2] NetworkPkg/HttpUtilitiesDxe: fix read memory access overflow Songpeng Li
1 sibling, 0 replies; 4+ messages in thread
From: Songpeng Li @ 2018-09-25 8:24 UTC (permalink / raw)
To: edk2-devel; +Cc: Fu Siyuan, Wu Jiaxin
The input param String of AsciiStrStr() requires a pointer to
Null-terminated string, however in HttpTcpReceiveHeader(),
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 | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/NetworkPkg/HttpDxe/HttpProto.c b/NetworkPkg/HttpDxe/HttpProto.c
index 94f89f5665..7d69429be7 100644
--- a/NetworkPkg/HttpDxe/HttpProto.c
+++ b/NetworkPkg/HttpDxe/HttpProto.c
@@ -1914,10 +1914,10 @@ HttpTcpReceiveHeader (
}
//
- // Append the response string.
+ // Append the response string along with a Null-terminator.
//
*BufferSize = *SizeofHeaders + Fragment.Len;
- Buffer = AllocateZeroPool (*BufferSize);
+ Buffer = AllocatePool (*BufferSize + 1);
if (Buffer == NULL) {
Status = EFI_OUT_OF_RESOURCES;
return Status;
@@ -1933,6 +1933,7 @@ HttpTcpReceiveHeader (
Fragment.Bulk,
Fragment.Len
);
+ *(Buffer + *BufferSize) = '\0';
*HttpHeaders = Buffer;
*SizeofHeaders = *BufferSize;
@@ -2013,10 +2014,10 @@ HttpTcpReceiveHeader (
}
//
- // Append the response string.
+ // Append the response string along with a Null-terminator.
//
*BufferSize = *SizeofHeaders + Fragment.Len;
- Buffer = AllocateZeroPool (*BufferSize);
+ Buffer = AllocatePool (*BufferSize + 1);
if (Buffer == NULL) {
Status = EFI_OUT_OF_RESOURCES;
return Status;
@@ -2032,6 +2033,7 @@ HttpTcpReceiveHeader (
Fragment.Bulk,
Fragment.Len
);
+ *(Buffer + *BufferSize) = '\0';
*HttpHeaders = Buffer;
*SizeofHeaders = *BufferSize;
--
2.18.0.windows.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] NetworkPkg/HttpUtilitiesDxe: fix read memory access overflow.
2018-09-25 8:24 [PATCH 0/2] fix read memory access overflow in HTTPBoot Songpeng Li
2018-09-25 8:24 ` [PATCH 1/2] NetworkPkg/HttpDxe: " Songpeng Li
@ 2018-09-25 8:24 ` Songpeng Li
1 sibling, 0 replies; 4+ messages in thread
From: Songpeng Li @ 2018-09-25 8:24 UTC (permalink / raw)
To: edk2-devel; +Cc: Fu Siyuan, Wu Jiaxin
The input param String of AsciiStrStr() requires a pointer to
Null-terminated string, however in 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/HttpUtilitiesDxe/HttpUtilitiesProtocol.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesProtocol.c b/NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesProtocol.c
index a9a1c7c586..b0e3e7f081 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,12 +312,17 @@ HttpUtilitiesParse (
return EFI_INVALID_PARAMETER;
}
- TempHttpMessage = AllocateZeroPool (HttpMessageSize);
+ //
+ // Append the http response string along with a Null-terminator.
+ //
+ HttpBufferSize = HttpMessageSize + 1;
+ TempHttpMessage = AllocatePool (HttpBufferSize);
if (TempHttpMessage == NULL) {
return EFI_OUT_OF_RESOURCES;
}
CopyMem (TempHttpMessage, HttpMessage, HttpMessageSize);
+ *(TempHttpMessage + HttpMessageSize) = '\0';
//
// Get header number
--
2.18.0.windows.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 0/2] fix read memory access overflow in HTTPBoot.
@ 2018-09-28 1:57 Songpeng Li
0 siblings, 0 replies; 4+ messages in thread
From: Songpeng Li @ 2018-09-28 1:57 UTC (permalink / raw)
To: edk2-devel
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.
Songpeng Li (2):
NetworkPkg/HttpDxe: fix read memory access overflow in HTTPBoot.
NetworkPkg/HttpUtilitiesDxe: fix read memory access overflow.
NetworkPkg/HttpDxe/HttpProto.c | 10 ++++++----
NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesProtocol.c | 8 +++++++-
2 files changed, 13 insertions(+), 5 deletions(-)
--
2.18.0.windows.1
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-09-28 1:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-25 8:24 [PATCH 0/2] fix read memory access overflow in HTTPBoot Songpeng Li
2018-09-25 8:24 ` [PATCH 1/2] NetworkPkg/HttpDxe: " Songpeng Li
2018-09-25 8:24 ` [PATCH 2/2] NetworkPkg/HttpUtilitiesDxe: fix read memory access overflow Songpeng Li
-- strict thread matches above, loose matches on Subject: below --
2018-09-28 1:57 [PATCH 0/2] fix read memory access overflow in HTTPBoot Songpeng Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox