A crafted input will lead to crash in frompnm.c at libsixel 1.8.3.(git from the branch )
Triggered by:
./img2sixel 000-memleak-rpl_malloc
Poc:
000-memleak-rpl_malloc
The ASAN info:
# ./img2sixel 000-memleak-rpl_malloc
runtime error: integer overflow
safe_addition_for_params: ingeger overflow detected.
=================================================================
==9353==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 64 byte(s) in 1 object(s) allocated from:
#0 0x7f99a109eb50 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb50)
#1 0x5583fae75543 in rpl_malloc /home/liuz/libsixel-2019/libsixel/converters/malloc_stub.c:45
#2 0x7f99a0d76834 in sixel_allocator_malloc /home/liuz/libsixel-2019/libsixel/src/allocator.c:155
#3 0x7f99a0d03b74 in image_buffer_resize /home/liuz/libsixel-2019/libsixel/src/fromsixel.c:293
#4 0x7f99a0d057ed in sixel_decode_raw_impl /home/liuz/libsixel-2019/libsixel/src/fromsixel.c:590
#5 0x7f99a0d08031 in sixel_decode_raw /home/liuz/libsixel-2019/libsixel/src/fromsixel.c:925
#6 0x7f99a0d57a16 in load_sixel /home/liuz/libsixel-2019/libsixel/src/loader.c:619
#7 0x7f99a0d58c1a in load_with_builtin /home/liuz/libsixel-2019/libsixel/src/loader.c:788
#8 0x7f99a0d5989f in sixel_helper_load_image_file /home/liuz/libsixel-2019/libsixel/src/loader.c:1368
#9 0x7f99a0d691d6 in sixel_encoder_encode /home/liuz/libsixel-2019/libsixel/src/encoder.c:1737
#10 0x5583fae7532e in main /home/liuz/libsixel-2019/libsixel/converters/img2sixel.c:457
#11 0x7f99a08f7b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
SUMMARY: AddressSanitizer: 64 byte(s) leaked in 1 allocation(s).
about code:
image_buffer_resize(
image_buffer_t *image,
int width,
int height,
int bgindex,
sixel_allocator_t *allocator)
{
SIXELSTATUS status = SIXEL_FALSE;
size_t size;
unsigned char *alt_buffer;
int n;
int min_height;
size = (size_t)(width * height);
-> alt_buffer = (unsigned char *)sixel_allocator_malloc(allocator, size);
if (alt_buffer == NULL || size == 0) {
/* free source image */
sixel_allocator_free(allocator, image->data
A crafted input will lead to crash in frompnm.c at libsixel 1.8.3.(git from the branch )
Triggered by:
./img2sixel 000-memleak-rpl_malloc
Poc:
000-memleak-rpl_malloc
The ASAN info:
about code: