bugThe FreeType Project - Bugs: bug #35658, Out-of-bounds read in _bdf_atos

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #35658: Out-of-bounds read in _bdf_atos

Submitter:  Mateusz Jurczyk <j00ru>
Submitted:  Tue 28 Feb 2012 10:19:16 AM UTC
 
Severity:  3 - Normal Item Group:  Crash
Status:  Fixed Privacy:  Public
Assigned to:  wl Open/Closed:  Closed
Planned Release:  2.4.9

Fri 16 Mar 2012 08:13:23 PM UTC, comment #3: 

Fixed, thanks!

Werner LEMBERG <wl>
Project Administrator
Fri 16 Mar 2012 07:24:01 PM UTC, comment #2: 

The fix that got committed is:
http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=d9c1659610f9cd5e103790cb5963483d65cf0d2d

I wonder if it's actually correct.  In _bdf_list_split, fields 0 to 3 are re-initialized, but it seems field 4 should be re-initialized too (as that's used for BBX and FONTBOUNDINGBOX).  Well, actually re-initializing 1 to 4 should be sufficient, as at least one field gets written to if _bdf_list_split does not end with error.

That should get the code in sync with cee5d593582801f65c5e127d9de9ca24ebcdc747.

Tomas Hoger <thoger>
Thu 01 Mar 2012 08:33:33 PM UTC, comment #1: 

Fixed in git, thanks.

Werner LEMBERG <wl>
Project Administrator
Tue 28 Feb 2012 10:19:16 AM UTC, original submission:  

Crash tested with ftbench (current git branch of freetype2 and ft2demos), compiled under Ubuntu amd64 with AddressSanitizer (http://code.google.com/p/address-sanitizer/).

Crashlog from ASAN:

==10161== ERROR: AddressSanitizer heap-buffer-overflow on address 0x7f9553cb7480 at pc 0x56ecf7 bp 0x7fff0a770ce0 sp 0x7fff0a770cd8
READ of size 1 at 0x7f9553cb7480 thread T0
  #0 0x56ecf7 _bdf_atos
  #1 0x571b2a _bdf_parse_glyphs
  #2 0x56b116 _bdf_readstream
  #3 0x5692b9 bdf_load_font
  #4 0x56634d BDF_Face_Init
  #5 0x4912d0 open_face
  #6 0x490893 FT_Open_Face
  #7 0x48fbf6 FT_New_Face
  #8 0x487407 get_face
  #9 0x487b61 main
  #10 0x7f955490bd5d __libc_start_main
0x7f9553cb7480 is located 0 bytes to the right of 1024-byte region [0x7f9553cb7080,0x7f9553cb7480)
allocated by thread T0 here:
  #0 0x5c3d92 malloc
  #1 0x4a0ce4 ft_mem_qalloc
  #2 0x48b28f ft_mem_alloc
  #3 0x4a38c2 ft_mem_qrealloc
  #4 0x48bb8d ft_mem_realloc
  #5 0x56af6d _bdf_readstream
  #6 0x5692b9 bdf_load_font
  #7 0x56634d BDF_Face_Init
  #8 0x4912d0 open_face
  #9 0x490893 FT_Open_Face
  #10 0x48fbf6 FT_New_Face
  #11 0x487407 get_face
  #12 0x487b61 main
  #13 0x7f955490bd5d __libc_start_main
==10161== ABORTING
Stats: 0M malloced (0M for red zones) by 826 calls
Stats: 0M realloced by 4 calls
Stats: 0M freed by 32 calls
Stats: 0M really freed by 0 calls
Stats: 40M (10246 full pages) mmaped in 10 calls
  mmaps   by size class: 8:16383; 9:8191; 10:4095; 11:2047; 12:1024; 13:512; 14:256; 15:128; 19:8; 20:4;
  mallocs by size class: 8:789; 9:17; 10:6; 11:6; 12:3; 13:1; 14:1; 15:1; 19:1; 20:1;
  frees   by size class: 8:19; 9:3; 10:6; 11:2; 12:1; 13:1;
  rfrees  by size class:
Stats: malloc large: 2 small slow: 9
Shadow byte and word:
  0x1ff2aa796e90: fa
  0x1ff2aa796e90: fa fa fa fa fa fa fa fa
More shadow bytes:
  0x1ff2aa796e70: 00 00 00 00 00 00 00 00
  0x1ff2aa796e78: 00 00 00 00 00 00 00 00
  0x1ff2aa796e80: 00 00 00 00 00 00 00 00
  0x1ff2aa796e88: 00 00 00 00 00 00 00 00
=>0x1ff2aa796e90: fa fa fa fa fa fa fa fa
  0x1ff2aa796e98: fa fa fa fa fa fa fa fa
  0x1ff2aa796ea0: fa fa fa fa fa fa fa fa
  0x1ff2aa796ea8: fa fa fa fa fa fa fa fa

Log from Valgrind:

==19496== Memcheck, a memory error detector
==19496== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==19496== Using Valgrind-3.8.0.SVN and LibVEX; rerun with -h for copyright info
==19496== Command: ./ftbench tmp/freetype_run2/timesbi7.bdf.asan.47.837
==19496==
==19496== Invalid read of size 1
==19496==    at 0x451643: _bdf_atos (freetype2/src/bdf/bdflib.c:987)
==19496==    by 0x453444: _bdf_parse_glyphs (freetype2/src/bdf/bdflib.c:1832)
==19496==    by 0x4511FA: _bdf_readstream (freetype2/src/bdf/bdflib.c:765)
==19496==    by 0x454D69: bdf_load_font (freetype2/src/bdf/bdflib.c:2367)
==19496==    by 0x4560D8: BDF_Face_Init (freetype2/src/bdf/bdfdrivr.c:367)
==19496==    by 0x407F6F: open_face (freetype2/src/base/ftobjs.c:1153)
==19496==    by 0x4097F3: FT_Open_Face (freetype2/src/base/ftobjs.c:2080)
==19496==    by 0x40808C: FT_New_Face (freetype2/src/base/ftobjs.c:1215)
==19496==    by 0x402302: get_face (ft2demos-2.4.8/src/ftbench.c:624)
==19496==    by 0x4025F4: main (ft2demos-2.4.8/src/ftbench.c:752)
==19496==  Address 0x569a180 is 0 bytes after a block of size 1,024 alloc'd
==19496==    at 0x4C2A4D6: malloc (coregrind/m_replacemalloc/vg_replace_malloc.c:263)
==19496==    by 0x49441F: ft_alloc (freetype2/src/base/ftsystem.c:74)
==19496==    by 0x413466: ft_mem_qalloc (freetype2/src/base/ftutil.c:76)
==19496==    by 0x4133EE: ft_mem_alloc (freetype2/src/base/ftutil.c:55)
==19496==    by 0x413626: ft_mem_qrealloc (freetype2/src/base/ftutil.c:145)
==19496==    by 0x4134EB: ft_mem_realloc (freetype2/src/base/ftutil.c:101)
==19496==    by 0x450F4C: _bdf_readstream (freetype2/src/bdf/bdflib.c:676)
==19496==    by 0x454D69: bdf_load_font (freetype2/src/bdf/bdflib.c:2367)
==19496==    by 0x4560D8: BDF_Face_Init (freetype2/src/bdf/bdfdrivr.c:367)
==19496==    by 0x407F6F: open_face (freetype2/src/base/ftobjs.c:1153)
==19496==    by 0x4097F3: FT_Open_Face (freetype2/src/base/ftobjs.c:2080)
==19496==    by 0x40808C: FT_New_Face (freetype2/src/base/ftobjs.c:1215)
==19496==
==19496== Invalid read of size 1
==19496==    at 0x45165B: _bdf_atos (freetype2/src/bdf/bdflib.c:987)
==19496==    by 0x453444: _bdf_parse_glyphs (freetype2/src/bdf/bdflib.c:1832)
==19496==    by 0x4511FA: _bdf_readstream (freetype2/src/bdf/bdflib.c:765)
==19496==    by 0x454D69: bdf_load_font (freetype2/src/bdf/bdflib.c:2367)
==19496==    by 0x4560D8: BDF_Face_Init (freetype2/src/bdf/bdfdrivr.c:367)
==19496==    by 0x407F6F: open_face (freetype2/src/base/ftobjs.c:1153)
==19496==    by 0x4097F3: FT_Open_Face (freetype2/src/base/ftobjs.c:2080)
==19496==    by 0x40808C: FT_New_Face (freetype2/src/base/ftobjs.c:1215)
==19496==    by 0x402302: get_face (ft2demos-2.4.8/src/ftbench.c:624)
==19496==    by 0x4025F4: main (ft2demos-2.4.8/src/ftbench.c:752)
==19496==  Address 0x569a180 is 0 bytes after a block of size 1,024 alloc'd
==19496==    at 0x4C2A4D6: malloc (coregrind/m_replacemalloc/vg_replace_malloc.c:263)
==19496==    by 0x49441F: ft_alloc (freetype2/src/base/ftsystem.c:74)
==19496==    by 0x413466: ft_mem_qalloc (freetype2/src/base/ftutil.c:76)
==19496==    by 0x4133EE: ft_mem_alloc (freetype2/src/base/ftutil.c:55)
==19496==    by 0x413626: ft_mem_qrealloc (freetype2/src/base/ftutil.c:145)
==19496==    by 0x4134EB: ft_mem_realloc (freetype2/src/base/ftutil.c:101)
==19496==    by 0x450F4C: _bdf_readstream (freetype2/src/bdf/bdflib.c:676)
==19496==    by 0x454D69: bdf_load_font (freetype2/src/bdf/bdflib.c:2367)
==19496==    by 0x4560D8: BDF_Face_Init (freetype2/src/bdf/bdfdrivr.c:367)
==19496==    by 0x407F6F: open_face (freetype2/src/base/ftobjs.c:1153)
==19496==    by 0x4097F3: FT_Open_Face (freetype2/src/base/ftobjs.c:2080)
==19496==    by 0x40808C: FT_New_Face (freetype2/src/base/ftobjs.c:1215)
==19496==
_bdf_parse_glyphs: [line 308] Invalid keyword.
couldn't load font resource
==19496==
==19496== HEAP SUMMARY:
==19496==     in use at exit: 0 bytes in 0 blocks
==19496==   total heap usage: 204 allocs, 204 frees, 895,538 bytes allocated
==19496==
==19496== All heap blocks were freed -- no leaks are possible
==19496==
==19496== For counts of detected and suppressed errors, rerun with: -v
==19496== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 4 from 4)

Mateusz Jurczyk <j00ru>
Project Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #25204:  timesbi7.bdf.asan.47.837 added by j00ru (134KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by thoger (Posted a comment)
  • -email is unavailable- added by wl (Posted a comment)
  • -email is unavailable- added by j00ru (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

     

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-03-01 wl StatusNone Fixed
        PrivacyPrivate Public
        Assigned toNone wl
        Open/ClosedOpen Closed
        Planned ReleaseNone 2.4.9
    2012-02-28 j00ru Attached File- Added timesbi7.bdf.asan.47.837, #25204

    Back to the top


    Powered by Savane 3.9