RfidResearchGroup / proxmark3

Iceman Fork - Proxmark3
http://www.icedev.se
GNU General Public License v3.0
3.62k stars 979 forks source link

Use of free() in armsrc/desfire_crypto.c #2384

Closed jlitewski closed 1 month ago

jlitewski commented 1 month ago

Now I'm not a smart man, but this could possibly cause problems, correct? Seems to have been here for about 4 years now.

https://github.com/RfidResearchGroup/proxmark3/blame/2bc7c5030234e43a1436d98bb7f5fec34802f29c/armsrc/desfire_crypto.c#L633

iceman1001 commented 1 month ago

Depends on what the data stored in that pointer does in that particular code path.
If its not used, free is ok to call onto it since its a local pointer.

henrygab commented 1 month ago

@iceman1001 ... this does appear to be a memory corruption.

Here's one codepath:

@jlitewski -- Looks to me like you found a memory corruption bug caused by mismatch allocator / deallocator.

Nice catch!

iceman1001 commented 1 month ago

Its even worse, since we don't use any malloc/calloc, but a bigbuffer alloc, we never should use a call to free
Its a bug.