test: add tests for zero sized realloc(3)#255
Conversation
|
This will break real world applications and isn't actually memory corruption, resulting in reduced security from not being able to use those applications from hardened_malloc. |
|
The safest way to handle this is the way it already does: treating it the same way as malloc(0) by resizing to a 0 size allocation, which with hardened_malloc points to PROT_NONE memory with a unique address meeting the minimum alignment requirements for malloc despite it having a usable size of 0. |
|
Dropped the change in behavior, and added some additional test cases. |
|
Kindly ping |
9d5802c to
074d47a
Compare
|
Can you rebase this? |
C23 declared calling realloc(3) with a non-NULL pointer and zero size Undefined behavior. Check that hardened_malloc handles that case sanely by free'ing the old pointer and returning a special pointer, like `malloc(3)` called with size zero.
done |
|
The tests should probably be renamed to avoid specifically referencing C23 and undefined behavior, just naming them based on the edge cases which we're checking for. |
C23 declared calling realloc(3) with a non-NULL pointer and zero size Undefined behavior.
Check that hardened_malloc handles that case sanely by free'ing the old pointer and returning a special pointer, like
malloc(3)called with size zero.