bugAVR C Runtime Library - Bugs: bug #53284, realloc() does not respect...


bug #53284: realloc() does not respect __freelist size for small allocations

Submitted by:  David Glaze <djglaze>
Submitted on:  Sun 04 Mar 2018 10:19:44 PM UTC  
Category: LibrarySeverity: 3 - Normal
Priority: 5 - NormalItem Group: libc code
Status: NonePercent Complete: 0%
Assigned to: NoneOpen/Closed: Open
Release: 2.0.0Fixed Release: None

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Sun 04 Mar 2018 10:19:44 PM UTC, original submission:

The realloc() function does not respect the __freelist size when resizing an allocation down to 0 or 1 bytes. If this allocation is then deallocated with free(), a __freelist entry is placed in its slot that can partially overwrite an adjacent allocation, leading to irrecoverable memory corruption. The following code can reproduce the corruption:

malloc() handles this issue with a minimum allocation size, so that requested allocations of 0, 1, or 2 bytes all take the same storage. The same technique can be used here to prevent problems, as shown in the attached patch.

David Glaze <djglaze>


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

Attach File(s):

Attached Files
file #43463:  realloc_small_size.patch added by djglaze (614B - text/x-patch)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by djglaze (Submitted the item)

    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follows 1 latest change.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 04 Mar 2018 10:19:44 PM UTCdjglazeAttached File-=>Added realloc_small_size.patch, #43463

    Back to the top

    Powered by Savane 3.1-cleanup1