Unshar scans the input files (typically email messages) looking for the

start of a shell archive. If no files are given, then standard input is

processed instead. Shipped along with Sharutils.

Bug was found with AFL.

=================================================================

==11164==ERROR: AddressSanitizer: heap-buffer-overflow on address

0xb5901100 at pc 0x0804c695 bp 0xbfe86f28 sp 0xbfe86f18

READ of size 1 at 0xb5901100 thread T0

Â Â Â  #0 0x804c694 in looks_like_c_code

/home/john/sharutils-4.15.2/src/unshar.c:75

Â Â Â  #1 0x804c694 in find_archive

/home/john/sharutils-4.15.2/src/unshar.c:253

Â Â Â  #2 0x804c694 in unshar_file /home/john/sharutils-4.15.2/src/unshar.c:379

Â Â Â  #3 0x804a2f4 in validate_fname

/home/john/sharutils-4.15.2/src/unshar-opts.c:604

Â Â Â  #4 0x804a2f4 in main /home/john/sharutils-4.15.2/src/unshar-opts.c:639

Â Â Â  #5 0xb70ab636 in __libc_start_main

(/lib/i386-linux-gnu/libc.so.6+0x18636)

Â Â Â  #6 0x804ab95Â  (/home/john/sharutils-4.15.2/src/unshar+0x804ab95)

0xb5901100 is located 0 bytes to the right of 4096-byte region

[0xb5900100,0xb5901100)

allocated by thread T0 here:

Â Â Â  #0 0xb72dfdee in malloc (/usr/lib/i386-linux-gnu/libasan.so.2+0x96dee)

Â Â Â  #1 0x804c9e4 in init_unshar /home/john/sharutils-4.15.2/src/unshar.c:450

Â Â Â  #2 0xb70ab636 in __libc_start_main

(/lib/i386-linux-gnu/libc.so.6+0x18636)

SUMMARY: AddressSanitizer: heap-buffer-overflow

/home/john/sharutils-4.15.2/src/unshar.c:75 looks_like_c_code

Shadow bytes around the buggy address:

Â  0x36b201d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Â  0x36b201e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Â  0x36b201f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Â  0x36b20200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Â  0x36b20210: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

=>0x36b20220:[fa]fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa

Â  0x36b20230: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa

Â  0x36b20240: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa

Â  0x36b20250: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa

Â  0x36b20260: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa

Â  0x36b20270: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa

Shadow byte legend (one shadow byte represents 8 application bytes):

Â  Addressable:Â Â Â Â Â Â Â Â Â Â  00

Â  Partially addressable: 01 02 03 04 05 06 07

Â  Heap left redzone:Â Â Â Â Â Â  fa

Â  Heap right redzone:Â Â Â Â Â  fb

Â  Freed heap region:Â Â Â Â Â Â  fd

Â  Stack left redzone:Â Â Â Â Â  f1

Â  Stack mid redzone:Â Â Â Â Â Â  f2

Â  Stack right redzone:Â Â Â Â  f3

Â  Stack partial redzone:Â Â  f4

Â  Stack after return:Â Â Â Â Â  f5

Â  Stack use after scope:Â Â  f8

Â  Global redzone:Â Â Â Â Â Â Â Â Â  f9

Â  Global init order:Â Â Â Â Â Â  f6

Â  Poisoned by user:Â Â Â Â Â Â Â  f7

Â  Container overflow:Â Â Â Â Â  fc

Â  Array cookie:Â Â Â Â Â Â Â Â Â Â Â  ac

Â  Intra object redzone:Â Â Â  bb

Â  ASan internal:Â Â Â Â Â Â Â Â Â Â  fe

==11164==ABORTING

Thanks,

nafiez