global-buffer-overflow in conv_pattern_index() function
Xfig is a diagramming tool
Brought to you by:
tklxfiguser
Hi
I found a global-buffer-overflow in conv_pattern_index() at gencgm.c:533
Please run following command to reproduce it,
fig2dev -L cgm $PoC
Here's log
An open polygon at line 31 - close it.
=================================================================
==27666==ERROR: AddressSanitizer: global-buffer-overflow on address 0x55d8bbafa358 at pc 0x55d8bb7759da bp 0x7ffd22f17220 sp 0x7ffd22f17210
READ of size 4 at 0x55d8bbafa358 thread T0
#0 0x55d8bb7759d9 in conv_pattern_index fig2dev-3.2.7b/fig2dev/dev/gencgm.c:533
#1 0x55d8bb775a20 in hatchindex fig2dev-3.2.7b/fig2dev/dev/gencgm.c:543
#2 0x55d8bb776d1d in shape fig2dev-3.2.7b/fig2dev/dev/gencgm.c:638
#3 0x55d8bb77cbc4 in gencgm_line fig2dev-3.2.7b/fig2dev/dev/gencgm.c:1044
#4 0x55d8bb75aa3f in gendev_objects fig2dev-3.2.7b/fig2dev/fig2dev.c:1003
#5 0x55d8bb7592bf in main fig2dev-3.2.7b/fig2dev/fig2dev.c:480
#6 0x7fe59b3a7b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
#7 0x55d8bb749979 in _start (fig2dev-3.2.7b+0x6e979)
0x55d8bbafa358 is located 0 bytes to the right of global variable 'map_pattern' defined in 'gencgm.c:138:5' (0x55d8bbafa300) of size 88
0x55d8bbafa358 is located 40 bytes to the left of global variable 'oldfillcolor' defined in 'gencgm.c:490:12' (0x55d8bbafa380) of size 4
SUMMARY: AddressSanitizer: global-buffer-overflow fig2dev-3.2.7b/fig2dev/dev/gencgm.c:533 in conv_pattern_index
Shadow bytes around the buggy address:
0x0abb97757410: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0abb97757420: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0abb97757430: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0abb97757440: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0abb97757450: 00 00 00 00 00 00 00 00 00 00 00 00 f9 f9 f9 f9
=>0x0abb97757460: 00 00 00 00 00 00 00 00 00 00 00[f9]f9 f9 f9 f9
0x0abb97757470: 04 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9
0x0abb97757480: 04 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9
0x0abb97757490: 04 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9
0x0abb977574a0: 04 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9
0x0abb977574b0: 04 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9
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
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
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
Left alloca redzone: ca
Right alloca redzone: cb
==27666==ABORTING
fig2dev Version 3.2.7b
I also tested this in git Commit [3065ab] and can reproduce it.
I see
Could be similar to missing default color of issue #77
Also here some of the previous commits seems to mask out this error but shows now an other one:
Checking out fig2dev 3.2.7b and applying [2f8d1a], i.e., replacing on line 64 of fig2dev/object.h ">" by ">=", here this error does not show up any more. Therefore I believe commit [2f8d1a] fixes this and the original issue.
Related
Commit: [2f8d1a]
The attached file re-produces the original error. (An off-by-one error! Incidentally, it is the pattern no 63, in ticket #63; Maximum allowed pattern number is 62.) Fixed with commit [2f8d1a].
Related
Commit: [2f8d1a]
Last edit: tkl 2020-01-29