buglwIP - A Lightweight TCP/IP stack - Bugs: bug #62832, Allow NULL buffer to...


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

bug #62832: Allow NULL buffer to pbuf_get_contiguous()

Submitter:  Colin Foster <colin_foster_ia>
Submitted:  Thu 28 Jul 2022 06:40:23 PM UTC
Category:  pbufs Severity:  3 - Normal
Item Group:  Change Request Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open Planned Release:  None
lwIP version:  git head

Tue 23 Aug 2022 02:46:04 AM UTC, comment #3: 

If pbuf_get_contiguous returns null, the caller may mistakenly think that there is not enough data. You can rewrite a new function and let the caller call it according to his own needs.

wuchangsheng <wuchangsheng>
Mon 22 Aug 2022 03:24:14 PM UTC, comment #2: 

comment #1:

> When the required data spans more than one pbuf, null is passed in and the data cannot be copied out

That's the point I address below. If data spans more than one pbuf, NULL would be returned in which case further action (allocating a buffer on the stack, for example) would become necessary. But in cases where the payloads almost never (or actually never) span multiple pbufs, why force the user to always allocate a separate buffer that'll never get used?

Colin Foster <colin_foster_ia>
Mon 22 Aug 2022 02:53:19 PM UTC, comment #1: 

When the required data spans more than one pbuf, null is passed in and the data cannot be copied out

wuchangsheng <wuchangsheng>
Thu 28 Jul 2022 06:40:23 PM UTC, original submission:  

The pbuf_get_contiguous currently requires a non-NULL buffer and a non-zero buffer size:


It could be quite useful if an application could call it with NULL / 0, thus avoiding pbuf_copy_partial if possible, as well as memory allocation.

For instance:

struct foo *foo = pbuf_get_contiguous(pbuf, NULL, 0, sizeof(*foo), offset);
if (!foo)
  // error condition / malloc / stack call / etc

As it currently stands, additional stack would be required. For instance:

struct foo foo;
struct foo *pfoo = pbuf_get_contiguous(pbuf, &foo, sizeof(foo), sizeof(foo), offset);

Colin Foster <colin_foster_ia>


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

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by wuchangsheng (Posted a comment)
  • -email is unavailable- added by colin_foster_ia (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.


    No changes have been made to this item

    Back to the top

    Powered by Savane 3.12