cancel
Showing results for 
Search instead for 
Did you mean: 

Should be avoided using p->payload in LwIP examples?

JMarq.1
Associate III

I was looking at example HTTP IAP server provided in STM32F2xx package.

\STM32Cube\Repository\STM32Cube_FW_F2_V1.9.3\Projects\STM322xG_EVAL\Applications\LwIP\LwIP_IAP\Src\httpserver.c

In http_recv, received data is extracted on every chunk of data from p->payload assuming len = p->tot_len == p->len. If I'm not wrong, p->tot_len might be more than one pbuff (i.e. more than one p->payload).

Shouldn't routine pbuf_copy_partial used instead of accessing directly to payload field?

I mean, something like:

received_bytes = pbuf_copy_partial(p, getCmdBuffer, p->tot_len, 0);

2 REPLIES 2
MWB_CHa
ST Employee

Hi,

This issue has been confirmed and fixed with STM32F4 and not yet maintained in STM32F2.

You can use the patch attached to this post to fix the issue.

The maintenance for STM32F2 is not planned yet, but you can use the patch meanwhile.

I hope it helps.

if(len)
IAP_HTTP_writedata(ptr,len);

There are several such places in that file and your fix keeps that beginner level incompetent formatting. And then on another topic you are telling this:

the rationale is keeping the code easily readable and understandable

Couldn't be more hypocritical...