Detect Android LOKI'd boot bootimgs buffer_fill: fix double free of `ebuf` on read error (https://bugzilla.redhat.com/1685217) --- magic/Magdir/android | 4 +++- src/buffer.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) --- magic/Magdir/android +++ magic/Magdir/android 2019-06-11 10:34:41.940646113 +0000 @@ -19,7 +19,9 @@ # From https://android.googlesource.com/\ # platform/system/core/+/master/mkbootimg/bootimg.h 0 string ANDROID! Android bootimg ->1024 string LOKI\01 \b, LOKI'd +>1024 string LOKI \b, LOKI'd +>>1028 lelong 0 \b (boot) +>>1028 lelong 1 \b (recovery) >8 lelong >0 \b, kernel >>12 lelong >0 \b (0x%x) >16 lelong >0 \b, ramdisk --- src/buffer.c +++ src/buffer.c 2019-06-11 10:34:41.940646113 +0000 @@ -77,6 +77,7 @@ buffer_fill(const struct buffer *bb) b->eoff = b->st.st_size - b->elen; if (pread(b->fd, b->ebuf, b->elen, b->eoff) == -1) { free(b->ebuf); + b->ebuf = NULL; goto out; }