HTTPD p->payload PBUF not being cleared

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

HTTPD p->payload PBUF not being cleared

rcbuck
I have an httpd application running and am using POST to send data to the server. Calling pbuf_free(p) does not clear the p->payload buffer. I searched the list and found this post:
https://lists.nongnu.org/archive/html/lwip-users/2020-02/msg00023.html

Has this bug been corrected? If not, is there a manual work around to clear the payload buffer?

I am running LwIP on a STM32F407 processor board. I am not using a RTOS. If I perform a post and send as an example, abcdefgh23, the data is received correctly. If I then send again as an example, wzxcvbnm, p->payload contains wzxcvbnm23.

I am running LwIP Version 2.1.2.

Thank you.

Ray

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: HTTPD p->payload PBUF not being cleared

Mario Luzeiro
Hi Ray,

Thanks to your email I believe I fixed the bug in my project!
I just added the pbuf_free as mention in
https://lists.nongnu.org/archive/html/lwip-users/2020-02/msg00025.html

From what it is on the documentation:
http://www.nongnu.org/lwip/2_1_x/group__httpd.html#ga461409c8813c2a82ba63fde987c0e537
"ATTENTION: The application is responsible for freeing the pbufs passed in!"
I think it meant to not be fixed.

On the post you mention, what I think Simon refers is that an example in the sourcecode is missing that free, not the library itself.

On relation to your payload, I'm not sure about it.
"data clear" is not the same as "memory free'ed" it can be free but it is not zeroing it.
Unless what you describe is something else?

Regards,
Mario

________________________________________
From: lwip-users <lwip-users-bounces+mrluzeiro=[hidden email]> on behalf of [hidden email] <[hidden email]>
Sent: 03 July 2020 20:35
To: [hidden email]
Subject: [lwip-users] HTTPD p->payload PBUF not being cleared

I have an httpd application running and am using POST to send data to the server. Calling pbuf_free(p) does not clear the p->payload buffer. I searched the list and found this post:
https://lists.nongnu.org/archive/html/lwip-users/2020-02/msg00023.html

Has this bug been corrected? If not, is there a manual work around to clear the payload buffer?

I am running LwIP on a STM32F407 processor board. I am not using a RTOS. If I perform a post and send as an example, abcdefgh23, the data is received correctly. If I then send again as an example, wzxcvbnm, p->payload contains wzxcvbnm23.

I am running LwIP Version 2.1.2.

Thank you.

Ray

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: HTTPD p->payload PBUF not being cleared

rcbuck
In reply to this post by rcbuck
Mario,
 I had the pbuf_free(p)  function call at the end of the "httpd_post_receive_data" function. As you say, that was probably releasing the buffer. I found that in order to clear the p->payload buffer I had to add this code:
    pbuf_free(p);
    for(x=0; x<p->tot_len; x++)
    {
        strcpy(&tmpval[x], "0");
    }
    strcpy((char *)p, tmpval);
    return ERR_OK;
Since p is a pointer to void, I had to cast it to a char so I could fill it with null characters.
The tmpval variable is declared as "char tmpval[48]".
Now each time I send a POST to the application, p->payload contains the data I send with no stragglers left from the previous post.
Ray

-------- Original Message --------
Subject: Re: [lwip-users] HTTPD p->payload PBUF not being cleared
From: Mário_Luzeiro <[hidden email]>
Date: Fri, July 03, 2020 1:37 pm
To: Mailing list for lwIP users <[hidden email]>

Hi Ray,

Thanks to your email I believe I fixed the bug in my project!
I just added the pbuf_free as mention in
https://lists.nongnu.org/archive/html/lwip-users/2020-02/msg00025.html

From what it is on the documentation:
http://www.nongnu.org/lwip/2_1_x/group__httpd.html#ga461409c8813c2a82ba63fde987c0e537
"ATTENTION: The application is responsible for freeing the pbufs passed in!"
I think it meant to not be fixed.

On the post you mention, what I think Simon refers is that an example in the sourcecode is missing that free, not the library itself.

On relation to your payload, I'm not sure about it.
"data clear" is not the same as "memory free'ed" it can be free but it is not zeroing it.
Unless what you describe is something else?

Regards,
Mario

________________________________________
From: lwip-users <[hidden email]> on behalf of [hidden email] <[hidden email]>
Sent: 03 July 2020 20:35
To: [hidden email]
Subject: [lwip-users] HTTPD p->payload PBUF not being cleared

I have an httpd application running and am using POST to send data to the server. Calling pbuf_free(p) does not clear the p->payload buffer. I searched the list and found this post:
https://lists.nongnu.org/archive/html/lwip-users/2020-02/msg00023.html

Has this bug been corrected? If not, is there a manual work around to clear the payload buffer?

I am running LwIP on a STM32F407 processor board. I am not using a RTOS. If I perform a post and send as an example, abcdefgh23, the data is received correctly. If I then send again as an example, wzxcvbnm, p->payload contains wzxcvbnm23.

I am running LwIP Version 2.1.2.

Thank you.

Ray

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: HTTPD p->payload PBUF not being cleared

Mario Luzeiro
Hi Ray,

>   for(x=0; x<p->tot_len; x++)
>    {
>        strcpy(&tmpval[x], "0");
>    }
>    strcpy((char *)p, tmpval);

I'm not into lwIP development, so I don't know what is in that p pointer, but that clear code looks unusual to me...
if I need to clear memory I would use the memset C function

Mario

________________________________________
From: lwip-users <lwip-users-bounces+mrluzeiro=[hidden email]> on behalf of [hidden email] <[hidden email]>
Sent: 04 July 2020 06:39
To: Mailing list for lwIP users
Subject: Re: [lwip-users] HTTPD p->payload PBUF not being cleared

Mario,
 I had the pbuf_free(p)  function call at the end of the "httpd_post_receive_data" function. As you say, that was probably releasing the buffer. I found that in order to clear the p->payload buffer I had to add this code:
    pbuf_free(p);
    for(x=0; x<p->tot_len; x++)
    {
        strcpy(&tmpval[x], "0");
    }
    strcpy((char *)p, tmpval);
    return ERR_OK;
Since p is a pointer to void, I had to cast it to a char so I could fill it with null characters.
The tmpval variable is declared as "char tmpval[48]".
Now each time I send a POST to the application, p->payload contains the data I send with no stragglers left from the previous post.
Ray

-------- Original Message --------
Subject: Re: [lwip-users] HTTPD p->payload PBUF not being cleared
From: Mário_Luzeiro <[hidden email]<mailto:[hidden email]>>
Date: Fri, July 03, 2020 1:37 pm
To: Mailing list for lwIP users <[hidden email]<mailto:[hidden email]>>

Hi Ray,

Thanks to your email I believe I fixed the bug in my project!
I just added the pbuf_free as mention in
https://lists.nongnu.org/archive/html/lwip-users/2020-02/msg00025.html

From what it is on the documentation:
http://www.nongnu.org/lwip/2_1_x/group__httpd.html#ga461409c8813c2a82ba63fde987c0e537
"ATTENTION: The application is responsible for freeing the pbufs passed in!"
I think it meant to not be fixed.

On the post you mention, what I think Simon refers is that an example in the sourcecode is missing that free, not the library itself.

On relation to your payload, I'm not sure about it.
"data clear" is not the same as "memory free'ed" it can be free but it is not zeroing it.
Unless what you describe is something else?

Regards,
Mario

________________________________________
From: lwip-users <lwip-users-bounces+mrluzeiro=[hidden email]<mailto:lwip-users-bounces+mrluzeiro=[hidden email]>> on behalf of [hidden email]<mailto:[hidden email]> <[hidden email]<mailto:[hidden email]>>
Sent: 03 July 2020 20:35
To: [hidden email]<mailto:[hidden email]>
Subject: [lwip-users] HTTPD p->payload PBUF not being cleared

I have an httpd application running and am using POST to send data to the server. Calling pbuf_free(p) does not clear the p->payload buffer. I searched the list and found this post:
https://lists.nongnu.org/archive/html/lwip-users/2020-02/msg00023.html

Has this bug been corrected? If not, is there a manual work around to clear the payload buffer?

I am running LwIP on a STM32F407 processor board. I am not using a RTOS. If I perform a post and send as an example, abcdefgh23, the data is received correctly. If I then send again as an example, wzxcvbnm, p->payload contains wzxcvbnm23.

I am running LwIP Version 2.1.2.

Thank you.

Ray

_______________________________________________
lwip-users mailing list
[hidden email]<mailto:[hidden email]>
https://lists.nongnu.org/mailman/listinfo/lwip-users

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users