Gianni Calzetti

AN3928 bug, lwip http server with dynamic data

Discussion created by Gianni Calzetti on May 28, 2019
Latest reply on Jun 19, 2019 by Hui_Ma

The source code ( of AN3928 ("Web Server Using the MCF51CN Family and FreeRTOS") has a bug.

The problem is in function HTTP_SendDynamicData in http_server.c

If a WEB page with dynamic content inside (.SHTML or .FSL extension) is stored in SD card then the SSI parsing can produce wrong results.

Data from a file in SD is readed by blocks, the function HTTP_SendDynamicData searches the string "<!--#echo var=\"" in one block at a time, but if the block doesn't contain that string ENTIRELY this search will fail and the block is sent via ethernet without its dynamic variable.



BLOCK 0 ends with "<!--#ech"

BLOCK 1 starts with "o var=\"CHANNEL0"  etc


In function HTTP_SendDynamicData, row #554 in http_server.c, when it searches in BLOCK 0:

"if(( index_a = (uint8 *)strstr(dynamic_start,SSI_START) ) != NULL)"

Variable "index_a" will be NULL, so the SSI parsing never happens.


So it's not safe to have SSI web pages stored in SD card.


No problem if they are statically stored as const array in static_web_pages.c.