From: "Santhosh Kumar V via groups.io" <santhoshkumarv=ami.com@groups.io>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
Santhosh Kumar V <santhoshkumarv@ami.com>
Cc: Sivaraman Nainar <sivaramann@ami.com>,
Raj V Akilan <rajva@ami.com>,
Saloni Kasbekar <saloni.kasbekar@intel.com>,
Zachary Clark-williams <zachary.clark-williams@intel.com>
Subject: [edk2-devel] [PATCH] NetworkPkg:HttpDxe:CoverityIssues
Date: Fri, 10 May 2024 11:06:05 +0000 [thread overview]
Message-ID: <20240510110602.1561-1-santhoshkumarv@ami.com> (raw)
Resolved Coverity Issues in Http Dxe
1.HttpResponseWorker(DEADCODE)
The result of pointer arithmetic "HttpHeaders + AsciiStrLen("HTTP/1.1") + 1" is never null.
2.HttpDns4 (DEAD LOOP)
Coverity reports dead loop error since IsDone is always false ,In Some scenario it might not update the to true
3.HttpsSupport.c (NULL_RETURNS)
NetbufAlloc ,NetbufAllocSpace might return null pointer ,so Assigning: "NULL" to "PacketOut" and "DataOut" pointer.
Cc: Saloni Kasbekar <saloni.kasbekar@intel.com>
Cc: Zachary Clark-williams <zachary.clark-williams@intel.com>
Signed-off-by: SanthoshKumarV <santhoshkumarv@ami.com>
---
NetworkPkg/HttpDxe/HttpDns.c | 2 +-
NetworkPkg/HttpDxe/HttpImpl.c | 5 +----
NetworkPkg/HttpDxe/HttpsSupport.c | 21 ++++++++++++++++++++-
3 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/NetworkPkg/HttpDxe/HttpDns.c b/NetworkPkg/HttpDxe/HttpDns.c
index 13cbde0f34..b8ac6fba4b 100644
--- a/NetworkPkg/HttpDxe/HttpDns.c
+++ b/NetworkPkg/HttpDxe/HttpDns.c
@@ -150,7 +150,7 @@ HttpDns4 (
goto Exit;
}
- while (!IsDone) {
+ while (!IsDone && (Dns4->Poll != NULL)) {
Dns4->Poll (Dns4);
}
diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c
index 6606c29342..6d05c203b0 100644
--- a/NetworkPkg/HttpDxe/HttpImpl.c
+++ b/NetworkPkg/HttpDxe/HttpImpl.c
@@ -1104,10 +1104,7 @@ HttpResponseWorker (
// Search for Status Code.
//
StatusCodeStr = HttpHeaders + AsciiStrLen (HTTP_VERSION_STR) + 1;
- if (StatusCodeStr == NULL) {
- Status = EFI_NOT_READY;
- goto Error;
- }
+
StatusCode = AsciiStrDecimalToUintn (StatusCodeStr);
diff --git a/NetworkPkg/HttpDxe/HttpsSupport.c b/NetworkPkg/HttpDxe/HttpsSupport.c
index 8d7bffe1e9..e40386a99c 100644
--- a/NetworkPkg/HttpDxe/HttpsSupport.c
+++ b/NetworkPkg/HttpDxe/HttpsSupport.c
@@ -732,7 +732,6 @@ TlsConfigureSession (
// the caller. The failure is pushed back to TLS DXE driver if the
// HTTP communication actually requires certificate.
//
- Status = EFI_SUCCESS;
} else {
DEBUG ((DEBUG_ERROR, "TLS Certificate Config Error!\n"));
return Status;
@@ -1250,6 +1249,10 @@ TlsConnectSession (
// Transmit ClientHello
//
PacketOut = NetbufAlloc ((UINT32)BufferOutSize);
+ if (PacketOut == NULL) {
+ FreePool (BufferOut);
+ return EFI_OUT_OF_RESOURCES;
+ }
DataOut = NetbufAllocSpace (PacketOut, (UINT32)BufferOutSize, NET_BUF_TAIL);
if (DataOut == NULL) {
FreePool (BufferOut);
@@ -1336,6 +1339,10 @@ TlsConnectSession (
// Transmit the response packet.
//
PacketOut = NetbufAlloc ((UINT32)BufferOutSize);
+ if (PacketOut == NULL) {
+ FreePool (BufferOut);
+ return EFI_OUT_OF_RESOURCES;
+ }
DataOut = NetbufAllocSpace (PacketOut, (UINT32)BufferOutSize, NET_BUF_TAIL);
if (DataOut == NULL) {
FreePool (BufferOut);
@@ -1493,6 +1500,10 @@ TlsCloseSession (
}
PacketOut = NetbufAlloc ((UINT32)BufferOutSize);
+ if (PacketOut == NULL) {
+ FreePool (BufferOut);
+ return EFI_OUT_OF_RESOURCES;
+ }
DataOut = NetbufAllocSpace (PacketOut, (UINT32)BufferOutSize, NET_BUF_TAIL);
if (DataOut == NULL) {
FreePool (BufferOut);
@@ -1781,6 +1792,10 @@ HttpsReceive (
if (BufferOutSize != 0) {
PacketOut = NetbufAlloc ((UINT32)BufferOutSize);
+ if (PacketOut == NULL) {
+ FreePool (BufferOut);
+ return EFI_OUT_OF_RESOURCES;
+ }
DataOut = NetbufAllocSpace (PacketOut, (UINT32)BufferOutSize, NET_BUF_TAIL);
if (DataOut == NULL) {
FreePool (BufferOut);
@@ -1873,6 +1888,10 @@ HttpsReceive (
if (BufferOutSize != 0) {
PacketOut = NetbufAlloc ((UINT32)BufferOutSize);
+ if (PacketOut == NULL) {
+ FreePool (BufferOut);
+ return EFI_OUT_OF_RESOURCES;
+ }
DataOut = NetbufAllocSpace (PacketOut, (UINT32)BufferOutSize, NET_BUF_TAIL);
if (DataOut == NULL) {
FreePool (BufferOut);
--
2.42.0.windows.2
-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#118813): https://edk2.groups.io/g/devel/message/118813
Mute This Topic: https://groups.io/mt/106018538/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next reply other threads:[~2024-05-10 11:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-10 11:06 Santhosh Kumar V via groups.io [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-05-10 11:04 [edk2-devel] [PATCH] NetworkPkg:HttpDxe:CoverityIssues Santhosh Kumar V via groups.io
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=20240510110602.1561-1-santhoshkumarv@ami.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