Skip to content

HTTP IAP bug #69

@khevessy

Description

@khevessy

I think there is a potential bug in the HTTP IAP example. In the web server, there this code:

if (strncmp(data, "GET /", 5) == 0)
{
if ((strncmp(data, "GET /resetmcu.cgi", 17) ==0)&&(htmlpage == UploadDonePage))
{
htmlpage = ResetDonePage;
fs_open("/reset.html", &file);
hs->file = file.data;
hs->left = file.len;
pbuf_free(p);
/* send reset.html page */
send_data(pcb, hs);
resetpage = 1;
/* Tell TCP that we wish be to informed of data that has been
successfully sent by a call to the http_sent() function. */
tcp_sent(pcb, http_sent);
}
else
{
if (alreadyLoggedIn == 0)
{
/*send the login page (which is the index page) */
htmlpage = LoginPage;
fs_open("/index.html", &file);
hs->file = file.data;
hs->left = file.len;
pbuf_free(p);
/* send index.html page */
send_data(pcb, hs);
/* Tell TCP that we wish be to informed of data that has been
successfully sent by a call to the http_sent() function. */
tcp_sent(pcb, http_sent);
}
}
}

and
if (strncmp(data, "GET /", 5) == 0)
{
if ((strncmp(data, "GET /resetmcu.cgi", 17) ==0)&&(htmlpage == UploadDonePage))
{
htmlpage = ResetDonePage;
fs_open("/reset.html", &file);
hs->file = file.data;
hs->left = file.len;
pbuf_free(p);
/* send reset.html page */
send_data(pcb, hs);
resetpage = 1;
/* Tell TCP that we wish be to informed of data that has been
successfully sent by a call to the http_sent() function. */
tcp_sent(pcb, http_sent);
}
else
{
if (alreadyLoggedIn == 0)
{
/*send the login page (which is the index page) */
htmlpage = LoginPage;
fs_open("/index.html", &file);
hs->file = file.data;
hs->left = file.len;
pbuf_free(p);
/* send index.html page */
send_data(pcb, hs);
/* Tell TCP that we wish be to informed of data that has been
successfully sent by a call to the http_sent() function. */
tcp_sent(pcb, http_sent);
}
}
}

which is used for handling GET request. POST requests are handled in else if() clause on lines 272 and 308. However, when sending of the binary is already happening, this can cause problem when the binary will contain string GET / and it will be just at the beginning of the data packet (it happened to me). Then we will skip this one packet and won't write the data at all.
My proposal for solution would be either add a check for which page are we on to the line 232, or move the clause that is handling the raw data (from line 308) to the beginning of the if.

Similar problem is also in the STM32CubeF4 project, I'll make separate issue there as the code is a little bit different.

Metadata

Metadata

Assignees

Labels

ethEthernetlwipLightweight TCP/IPneeds clarificationNeeds clarification or inputs from the userprojectsProjects-related (demos, applications, examples) issue or pull-request.

Type

No type

Projects

Status

To do

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions