5 ms·
If I understand this correctly, the underlying problem is in GIFLib, which calls reallocatearray, a wrapper around realloc that guards against overflows when co
by Someone 7y ago
If I understand this correctly, the underlying problem is in GIFLib, which calls reallocatearray, a wrapper around realloc that guards against overflows when computing the size of the memory buffer to reallocate from the number of items and item size.
However, reading https://github.com/aseprite/giflib/blob/master/lib/openbsd-reallocarray.c https://github.com/aseprite/giflib/blob/master/lib/openbsd-r..., I don’t see how that could lead to a double-free, unless realloc double-frees, or unless a different reallocatearray gets linked in.
Also, that comment on how realloc isn’t portable feels scary. I can see that introduce subtle bugs in libraries used on a different platform from where it is developed.
Hence, I think one should forbid the use of raw ‘realloc’ in portable code.
- totony 7y agoMost likely this is getting linked https://code.woboq.org/userspace/glibc/malloc/reallocarray.c.html https://code.woboq.org/userspace/glibc/malloc/reallocarray.c... realloc on linux frees the ptr https://linux.die.net/man/3/realloc https://linux.die.net/man/3/realloc
- deleted 7y ago[deleted]
- jwilk 7y agoandroid-gif-drawable has an older copy of this lib: https://github.com/koral--/android-gif-drawable/blob/dev/android-gif-drawable/src/main/c/giflib/openbsd-reallocarray.c https://github.com/koral--/android-gif-drawable/blob/dev/and... Or perhaps the function from the libc was being used?