buglwIP - A Lightweight TCP/IP stack - Bugs: bug #59728, SSI tag expansion in HTTPD breaks...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #59728: SSI tag expansion in HTTPD breaks if nothing follows the tag in a file

Submitter:  Mike Kleshov <kleshov>
Submitted:  Sat 19 Dec 2020 06:48:16 AM UTC
   
 
Category:  apps Severity:  2 - Minor
Item Group:  Faulty Behaviour Status:  Fixed
Privacy:  Public Assigned to:  kleshov
Open/Closed:  Closed Planned Release:  None
lwIP version:  git head

Fri 01 Jan 2021 08:38:59 AM UTC, comment #3: 

committed c6777547f69022df9b600b09a076bf4481ac9bf3

Mike Kleshov <kleshov>
Group Member
Tue 29 Dec 2020 04:40:27 AM UTC, comment #2: 

Proposed fix, tested in my setup:

diff --git a/trunk/src/apps/http/httpd.c b/trunk/src/apps/http/httpd.c
--- a/trunk/src/apps/http/httpd.c (revision 6988)
+++ b/trunk/src/apps/http/httpd.c (working copy)
@@ -1610,6 +1610,11 @@
   }
 #endif /* LWIP_HTTPD_DYNAMIC_HEADERS */
 
+#if LWIP_HTTPD_SSI
+  if (hs->ssi && (hs->ssi->tag_state == TAG_SENDING)) {
+    /* nothing */
+  } else
+#endif
   /* Have we run out of file data to send? If so, we need to read the next
    block from the file. /
   if (hs->left == 0) {
@@ -1621,6 +1626,9 @@
 #if LWIP_HTTPD_SSI
   if (hs->ssi) {
     data_to_send = http_send_data_ssi(pcb, hs);
+    if (hs->ssi->tag_state == TAG_SENDING) {
+      return data_to_send;
+    }
   } else
 #endif /* LWIP_HTTPD_SSI */
   {

Mike Kleshov <kleshov>
Group Member
Mon 28 Dec 2020 02:08:06 PM UTC, comment #1: 

Trying to narrow it down.
The problem occurs when LWIP_HTTPD_SSI_MULTIPART is enabled. Apparently, the function http_send() can decide that it has sent all the data when in fact a tag was not expanded completely:

#if LWIP_HTTPD_SSI
  if (hs->ssi) {
    data_to_send = http_send_data_ssi(pcb, hs);
  } else
#endif /* LWIP_HTTPD_SSI */
  {
    data_to_send = http_send_data_nonssi(pcb, hs);
  }

  if ((hs->left == 0) && (fs_bytes_left(hs->handle) <= 0)) { <<< THIS CONDITION TRIGGERS EVEN THOUGH TAG EXPANSION IS NOT COMPLETE
    /* We reached the end of the file so this request is done.
     This adds the FIN flag right into the last data segment. /
    LWIP_DEBUGF(HTTPD_DEBUG, ("End of file.\n"));
    http_eof(pcb, hs);
    return 0;
  }

Apparently, the condition highlighted above should be corrected.

Mike Kleshov <kleshov>
Group Member
Sat 19 Dec 2020 06:48:16 AM UTC, original submission:  

The title says it all. For example, if a file consists of a single tag only like "<!--#data-->", tag expansion misbehaves. Adding a single byte after the tag (like a new line) fixes the problem.

Mike Kleshov <kleshov>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by kleshov (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-01-01 kleshov StatusReady For Test Fixed
        Assigned toNone kleshov
        Open/ClosedOpen Closed
    2020-12-29 kleshov StatusNone Ready For Test

    Back to the top

    Powered by Savane 3.13-bb6a.
    Corresponding source code