buglwIP - A Lightweight TCP/IP stack - Bugs: bug #50844, Wrong SSI tag handling if tag ends...

 
 

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

bug #50844: Wrong SSI tag handling if tag ends exactly at the end of 2xMSS buffer

Submitter:  Dmitry <gdi>
Submitted:  Fri 21 Apr 2017 07:31:17 AM UTC
   
 
Category:  apps Severity:  3 - Normal
Item Group:  Faulty Behaviour Status:  Fixed
Privacy:  Public Assigned to:  goldsimon
Open/Closed:  Closed Planned Release:  None
lwIP version:  1.4.1

Mon 24 Apr 2017 08:34:36 PM UTC, comment #4: 

Should be fixed, thanks for reporting.
And thanks for pushing me into adding 'contrib/addons/http/*' ;-)

Simon Goldschmidt <goldsimon>
Group administrator
Mon 24 Apr 2017 07:58:40 AM UTC, comment #3: 

So I found the version of http server with which I'm working. This is httpserver_raw from CVS repository http://cvs.savannah.gnu.org/viewvc/*checkout*/lwip/contrib/apps/httpserver_raw/httpd.c?revision=1.45

Dmitry <gdi>
Mon 24 Apr 2017 07:21:22 AM UTC, comment #2: 

Yes I'm using FatFS to store files. But I'm also working with httpserver_raw from Texas Instruments TivaWare library and there is no LWIP_HTTPD_DYNAMIC_FILE_READ setting. Maybe this is some old example of http server. But this issue is related also to a last httpd.c from lwip v2.0.x apps. I didn't test it with static files which are stored in internal flash memory.
For a v2.0.x the changes should be made in http_send_data_ssi function in a 1209 line:
-----------------
while((ssi->tag_state == TAG_SENDING) || (ssi->parse_left) && (err == ERR_OK)) {
-----------------

Dmitry <gdi>
Fri 21 Apr 2017 01:36:37 PM UTC, comment #1: 

To clarify: this only happens for LWIP_HTTPD_DYNAMIC_FILE_READ. And 2*MSS because the code limits to 2*MSS by default.

Simon Goldschmidt <goldsimon>
Group administrator
Fri 21 Apr 2017 07:31:17 AM UTC, original submission:  

I found a trouble in SSI handling in httpsever_raw application of lwip v1.4.1 and the same issue presented in v2.0.x too.
The issue is appeared if you have a long *.shtml file which size more of equal to 5840 bytes and if you have SSI tag which will has its closing '>' symbol in a 5840-th byte. In this case the hs->tag_state will switch to TAG_SENDING state and we will go to a next revolution of 'while' loop. But the hs->parse_left = 0 here and we will go out of loop without sending this last tag. And we won't send the continue of *shtml file too. It will ends here.
I've catch this situation in debugger see the attachment.
I'm also found a solution:
I've add the checking for a TAG_SENDING state to the loop expression.

    /* We have sent all the data that was already parsed so continue parsing
     the buffer contents looking for SSI tags. /
    while((hs->tag_state == TAG_SENDING) || (hs->parse_left) && (err == ERR_OK)) {

The same fix can be applied in appropriate place in lwip v2.0.x httpd example.

Dmitry <gdi>

 

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

Attached Files
file #40461:  hs-last-tag.png added by gdi (50KiB - image/png)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by goldsimon (Posted a comment)
  • -email is unavailable- added by gdi (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
    2017-04-24 goldsimon StatusNone Fixed
        Assigned toNone goldsimon
        Open/ClosedOpen Closed
    2017-04-21 gdi Attached File- Added hs-last-tag.png, #40461

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code