https://bugs.winehq.org/show_bug.cgi?id=45422
Bug ID: 45422 Summary: ./tools/sfnt2fon/sfnt2fon.c shows a heap buffer overflow fill_fontinfo() Product: Wine Version: 3.11 Hardware: x86 URL: https://bugs.winehq.org/show_bug.cgi?id=40330 OS: Linux Status: NEW Keywords: download, source, valgrind Severity: normal Priority: P2 Component: tools Assignee: wine-bugs@winehq.org Reporter: austinenglish@gmail.com Distribution: Gentoo
First noticed in #40330, with ASAN: ../tools/sfnt2fon/sfnt2fon -o sserifee.fon ms_sans_serif.ttf -d 129 13,1250,5 16,1250,7 ================================================================= ==18356==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xf5a06ab3 at pc 0x5658546e bp 0xffd67ec8 sp 0xffd67eb8 READ of size 1 at 0xf5a06ab3 thread T0 #0 0x5658546d in fill_fontinfo (/var/lib/jenkins/home/workspace/wine-gcc-asan/tools/sfnt2fon/sfnt2fon+0x946d) #1 0x56585da8 in main (/var/lib/jenkins/home/workspace/wine-gcc-asan/tools/sfnt2fon/sfnt2fon+0x9da8) #2 0xf7680302 in __libc_start_main (/lib32/libc.so.6+0x18302) #3 0x56582070 (/var/lib/jenkins/home/workspace/wine-gcc-asan/tools/sfnt2fon/sfnt2fon+0x6070)
0xf5a06ab3 is located 1 bytes to the right of 2-byte region [0xf5a06ab0,0xf5a06ab2) allocated by thread T0 here: #0 0xf7a42ed4 in malloc (/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/32/libasan.so.4+0xe5ed4) #1 0xf785e437 (/usr/lib32/libfreetype.so.6+0x9437)
SUMMARY: AddressSanitizer: heap-buffer-overflow (/var/lib/jenkins/home/workspace/wine-gcc-asan/tools/sfnt2fon/sfnt2fon+0x946d) in fill_fontinfo Shadow bytes around the buggy address: 0x3eb40d00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x3eb40d10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x3eb40d20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x3eb40d30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x3eb40d40: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa =>0x3eb40d50: fa fa fa fa fa fa[02]fa fa fa fd fa fa fa fd fa 0x3eb40d60: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd 0x3eb40d70: fa fa fd fa fa fa fd fd fa fa fd fa fa fa fd fd 0x3eb40d80: fa fa fd fa fa fa fd fa fa fa fd fa fa fa fd fa 0x3eb40d90: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x3eb40da0: 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 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 ==18356==ABORTING
Using Valgrind gets better line numbers: austin@valgrindbox ~/wine-valgrind/fonts $ . ~/src/wine-valgrind/scripts/vg-wrapper.sh
austin@valgrindbox ~/wine-valgrind/fonts $ valgrind make sserifee.fon ../tools/sfnt2fon/sfnt2fon -o sserifee.fon ms_sans_serif.ttf -d 129 13,1250,5 16,1250,7 ==20606== Invalid read of size 1 ==20606== at 0x10A91E: fill_fontinfo (sfnt2fon.c:577) ==20606== by 0x10AD1F: main (sfnt2fon.c:729) ==20606== Address 0x4be6f03 is 1 bytes after a block of size 2 alloc'd ==20606== at 0x482D58B: malloc (vg_replace_malloc.c:299) ==20606== by 0x487DD87: ft_alloc (ftsystem.c:102) ==20606== by 0x488592E: ft_mem_qalloc (ftutil.c:76) ==20606== by 0x488592E: ft_mem_alloc (ftutil.c:55) ==20606== by 0x488632E: ft_glyphslot_alloc_bitmap (ftobjs.c:490) ==20606== by 0x48C2D62: tt_sbit_decoder_alloc_bitmap (ttsbit.c:628) ==20606== by 0x48C2D62: tt_sbit_decoder_load_bitmap (ttsbit.c:1234) ==20606== by 0x48C2D62: tt_sbit_decoder_load_image (ttsbit.c:1439) ==20606== by 0x48C8265: tt_face_load_sbit_image (ttsbit.c:1616) ==20606== by 0x489F269: load_sbit_image (ttgload.c:2308) ==20606== by 0x489F269: TT_Load_Glyph (ttgload.c:2716) ==20606== by 0x489F269: tt_glyph_load (ttdriver.c:468) ==20606== by 0x4882E0F: FT_Load_Glyph (ftobjs.c:913) ==20606== by 0x488371D: FT_Load_Char (ftobjs.c:1051) ==20606== by 0x10A9F7: fill_fontinfo (sfnt2fon.c:550) ==20606== by 0x10AD1F: main (sfnt2fon.c:729) ==20606==