Reviewed-by: Jiaxin Wu <jiaxin...@intel.com>

-----Original Message-----
From: Zhang, Lubo 
Sent: Wednesday, December 16, 2015 3:26 PM
To: edk2-devel@lists.01.org
Cc: Fu, Siyuan; Ye, Ting; Wu, Jiaxin
Subject: [patch] MdeModulePkg:Fix a bug HttpLib can't parse last chunked data 
well

When HttpLib parsing the last chunked data down, the Http NextMsg pointer in 
the HttpBodyParserCallback function should point to the character after '/n' 
flag.

Cc: Fu Siyuan <siyuan...@intel.com>
Cc: Ye Ting <ting...@intel.com>
Cc: Wu Jiaxin <jiaxin...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <lubo.zh...@intel.com>
---
 MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c | 39 +++++++++++++++++-----------
 1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c 
b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
index 49fa80b..143baab 100644
--- a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
+++ b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
@@ -1159,25 +1159,11 @@ HttpParseMessageBody (
   for (Char = Body; Char < Body + BodyLength; ) {
 
     switch (Parser->State) {
     case BodyParserStateMax:
       return EFI_ABORTED;
-
-    case BodyParserComplete:
-      if (Parser->Callback != NULL) {
-        Status = Parser->Callback (
-                   BodyParseEventOnComplete,
-                   Char,
-                   0,
-                   Parser->Context
-                   );
-        if (EFI_ERROR (Status)) {
-          return Status;
-        }
-      }
-      return EFI_SUCCESS;
-    
+ 
     case BodyParserBodyIdentity:
       //
       // Identity transfer-coding, just notify user to save the body data.
       //
       if (Parser->Callback != NULL) {
@@ -1193,10 +1179,21 @@ HttpParseMessageBody (
       }
       Char += MIN (BodyLength, Parser->ContentLength - 
Parser->ParsedBodyLength);
       Parser->ParsedBodyLength += MIN (BodyLength, Parser->ContentLength - 
Parser->ParsedBodyLength);
       if (Parser->ParsedBodyLength == Parser->ContentLength) {
         Parser->State = BodyParserComplete;
+        if (Parser->Callback != NULL) {
+          Status = Parser->Callback (
+                     BodyParseEventOnComplete,
+                     Char,
+                     0,
+                     Parser->Context
+                     );
+          if (EFI_ERROR (Status)) {
+            return Status;
+          }
+        }
       }
       break;
 
     case BodyParserChunkSizeStart:
       //
@@ -1270,10 +1267,22 @@ HttpParseMessageBody (
       }
       
     case BodyParserLastCRLFEnd:
       if (*Char == '\n') {
         Parser->State = BodyParserComplete;
+        Char++;
+        if (Parser->Callback != NULL) {
+          Status = Parser->Callback (
+                     BodyParseEventOnComplete,
+                     Char,
+                     0,
+                     Parser->Context
+                     );
+          if (EFI_ERROR (Status)) {
+            return Status;
+          }
+        }
         break;
       } else {
         Parser->State = BodyParserStateMax;
         break;
       }
--
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to