You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by am...@apache.org on 2018/07/10 18:52:35 UTC

[trafficserver] branch master updated: Handle response parsing case where EOF happens before any data arrives.

This is an automated email from the ASF dual-hosted git repository.

amc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 712a5e6  Handle response parsing case where EOF happens before any data arrives.
712a5e6 is described below

commit 712a5e6501e43809d8a51d33473339b6e89d15e7
Author: Alan M. Carroll <am...@apache.org>
AuthorDate: Tue Jul 10 11:34:08 2018 -0500

    Handle response parsing case where EOF happens before any data arrives.
---
 proxy/hdrs/HdrTSOnly.cc | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/proxy/hdrs/HdrTSOnly.cc b/proxy/hdrs/HdrTSOnly.cc
index a9b9987..d67fc2e 100644
--- a/proxy/hdrs/HdrTSOnly.cc
+++ b/proxy/hdrs/HdrTSOnly.cc
@@ -100,13 +100,21 @@ HTTPHdr::parse_resp(HTTPParser *parser, IOBufferReader *r, int *bytes_used, bool
 
   do {
     int64_t b_avail = r->block_read_avail();
+    tmp = start = r->start();
 
-    if (b_avail <= 0 && eof == false) {
-      break;
+    // No data currently available.
+    if (b_avail <= 0) {
+      if (eof == false) { // more data may arrive later, return CONTINUE state.
+        break;
+      } else if (nullptr == start) {
+        // EOF on empty MIOBuffer - that's a fail, don't bother with parsing.
+        // (otherwise will attempt to attach_block a non-existent block)
+        state = PARSE_RESULT_ERROR;
+        break;
+      }
     }
 
-    tmp = start = r->start();
-    end         = start + b_avail;
+    end = start + b_avail;
 
     int heap_slot = m_heap->attach_block(r->get_current_block(), start);