]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NetworkPkg:Fix a bug the 2nd httpboot fail issue.
authorZhang Lubo <lubo.zhang@intel.com>
Mon, 21 Dec 2015 01:36:08 +0000 (01:36 +0000)
committerluobozhang <luobozhang@Edk2>
Mon, 21 Dec 2015 01:36:08 +0000 (01:36 +0000)
Httpboot over Ipv4 or Ipv6 stack,for both Identity and chunked transfer
mode,when the last data has been parsed by HttpLib, the
HttpInstance->NextMsg pointer should point a correct location.Now after
the first successful httpboot for ipv4 or ipv6,the
HttpInstance->NextMsgpoint the character after the last byte, it may
be a bad buffer if we don't receive another HttpHeader, so if call a
2nd httpboot, the wrong NextMsg pointer will cause the httpboot fail,
so we need to check this case in HttpBodyParserCallback function in
the first http boot process.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19423 6f19259b-4bc3-4df7-8a09-765794883524

NetworkPkg/HttpDxe/HttpImpl.c

index 0fa437dc327d977767987926fc26519fdd6e7a72..aee3de517ffb844f69dd0453bad6733f858196f1 100644 (file)
@@ -778,6 +778,8 @@ HttpBodyParserCallback (
   )\r
 {\r
   HTTP_TOKEN_WRAP               *Wrap;\r
+  UINTN                         BodyLength;\r
+  CHAR8                         *Body;\r
 \r
   if (EventType != BodyParseEventOnComplete) {\r
     return EFI_SUCCESS;\r
@@ -788,7 +790,14 @@ HttpBodyParserCallback (
   }\r
 \r
   Wrap = (HTTP_TOKEN_WRAP *) Context;\r
-  Wrap->HttpInstance->NextMsg = Data;\r
+  Body = Wrap->HttpToken->Message->Body;\r
+  BodyLength = Wrap->HttpToken->Message->BodyLength;\r
+  if (Data < Body + BodyLength) {\r
+    Wrap->HttpInstance->NextMsg = Data;\r
+  } else {\r
+    Wrap->HttpInstance->NextMsg = NULL;\r
+  }\r
+  \r
 \r
   //\r
   // Free Tx4Token or Tx6Token since already received corrsponding HTTP response.\r