]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
MdeModulePkg/DxeHttpLib: Check the input parameters for some APIs.
[mirror_edk2.git] / MdeModulePkg / Library / DxeHttpLib / DxeHttpLib.c
index 774bf7d7e56a39fd3b9e4226b16c264f8e4ef2eb..e53dce5e1bcbadf9917e448bcaab9b2471dece9c 100644 (file)
@@ -1399,6 +1399,10 @@ HttpIsMessageComplete (
 {\r
   HTTP_BODY_PARSER      *Parser;\r
 \r
+  if (MsgParser == NULL) {\r
+    return FALSE;\r
+  }\r
+\r
   Parser = (HTTP_BODY_PARSER*) MsgParser;\r
 \r
   if (Parser->State == BodyParserComplete) {\r
@@ -1500,6 +1504,7 @@ AsciiStrGetNextToken (
 \r
 \r
   @retval EFI_SUCCESS             The FieldName and FieldValue are set into HttpHeader successfully.\r
+  @retval EFI_INVALID_PARAMETER   The parameter is invalid.\r
   @retval EFI_OUT_OF_RESOURCES    Failed to allocate resources.\r
 \r
 **/\r
@@ -1514,6 +1519,10 @@ HttpSetFieldNameAndValue (
   UINTN                       FieldNameSize;\r
   UINTN                       FieldValueSize;\r
 \r
+  if (HttpHeader == NULL || FieldName == NULL || FieldValue == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   if (HttpHeader->FieldName != NULL) {\r
     FreePool (HttpHeader->FieldName);\r
   }\r
@@ -1731,10 +1740,6 @@ HttpGenRequestMessage (
   UINTN                            Index;\r
   EFI_HTTP_UTILITIES_PROTOCOL      *HttpUtilitiesProtocol;\r
 \r
-\r
-  ASSERT (Message != NULL);\r
-\r
-  *RequestMsg           = NULL;\r
   Status                = EFI_SUCCESS;\r
   HttpHdrSize           = 0;\r
   MsgSize               = 0;\r
@@ -1749,7 +1754,8 @@ HttpGenRequestMessage (
   // 3. If we do not have a Request, HeaderCount should be zero\r
   // 4. If we do not have Request and Headers, we need at least a message-body\r
   //\r
-  if ((Message->Data.Request != NULL && Url == NULL) ||\r
+  if ((Message == NULL || RequestMsg == NULL || RequestMsgSize == NULL) || \r
+      (Message->Data.Request != NULL && Url == NULL) ||\r
       (Message->Data.Request != NULL && Message->HeaderCount == 0) ||\r
       (Message->Data.Request == NULL && Message->HeaderCount != 0) ||\r
       (Message->Data.Request == NULL && Message->HeaderCount == 0 && Message->BodyLength == 0)) {\r
@@ -1830,6 +1836,7 @@ HttpGenRequestMessage (
   //\r
   // memory for the string that needs to be sent to TCP\r
   //\r
+  *RequestMsg           = NULL;\r
   *RequestMsg = AllocateZeroPool (MsgSize);\r
   if (*RequestMsg == NULL) {\r
     Status = EFI_OUT_OF_RESOURCES;\r
@@ -2055,7 +2062,15 @@ HttpIsValidHttpHeader (
 {\r
   UINTN                       Index;\r
 \r
+  if (FieldName == NULL) {\r
+    return FALSE;\r
+  }\r
+\r
   for (Index = 0; Index < DeleteCount; Index++) {\r
+    if (DeleteList[Index] == NULL) {\r
+      continue;\r
+    }\r
+    \r
     if (AsciiStrCmp (FieldName, DeleteList[Index]) == 0) {\r
       return FALSE;\r
     }\r