patchlwIP - A Lightweight TCP/IP stack - Patches: patch #5796, pbuf_alloc: len field claculation...

 
 

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

patch #5796: pbuf_alloc: len field claculation causes memory corruption

Submitter:  Simon Goldschmidt <goldsimon>
Submitted:  Sun 11 Mar 2007 05:15:19 PM UTC
   
 
Category:  None Priority:  7 - High
Status:  Done Privacy:  Public
Assigned to:  goldsimon Open/Closed:  Closed
Planned Release:  None

Wed 04 Apr 2007 07:31:15 PM UTC, comment #2: 

OK, this is integrated as of CVS file revision 1.86

closing this.

Simon Goldschmidt <goldsimon>
Group administrator
Mon 12 Mar 2007 08:48:28 AM UTC, comment #1: 

Sounds reasonable to me.  Also the assert is a good idea as I think that is assumed in a couple of other places too.

Kieran Mansley <kieranm>
Group Member
Sun 11 Mar 2007 05:15:19 PM UTC, original submission:  

When calling

pbuf_alloc(PBUF_LINK, size, PBUF_POOL)

with size > PBUF_POOL_BUFSIZE and if PBUF_LINK_HLEN is not a multiple of MEM_ALIGNMENT, the calculation of the 'len' field results in the pbuf being longer than its actual payload:

original code (offset is too small -> len is too long):

p->len = length > PBUF_POOL_BUFSIZE - offset? PBUF_POOL_BUFSIZE - offset: length;

patch:

p->len = length > PBUF_POOL_BUFSIZE - MEM_ALIGN_SIZE(offset)? PBUF_POOL_BUFSIZE - MEM_ALIGN_SIZE(offset): length;

This still relies on struct pbuf being a multiple of MEM_ALIGNMENT (which it may or may not be), so I also added an assert statement for this in pbuf_init().

If noone object, I'll check it in.

Simon Goldschmidt <goldsimon>
Group administrator

 

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

Attached Files
file #12172:  pbuf_pool_smallchunks.patch added by goldsimon (1KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2007-04-04 goldsimon Open/ClosedOpen Closed
    2007-04-04 goldsimon StatusIn Progress Done
    2007-03-11 goldsimon Attached File- Added pbuf_pool_smallchunks.patch, #12172

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code