bugThe FreeType Project - Bugs: bug #35597, Out-of-bounds read in strlen, bdf...

 
 

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

bug #35597: Out-of-bounds read in strlen, bdf parsing

Submitter:  Mateusz Jurczyk <j00ru>
Submitted:  Thu 23 Feb 2012 12:09:12 PM UTC
   
 
Severity:  3 - Normal Item Group:  Crash
Status:  Fixed Privacy:  Public
Assigned to:  wl Open/Closed:  Closed
Planned Release:  2.4.9

Sun 26 Feb 2012 07:15:00 AM UTC, comment #1: 

Fixed in git, thanks.

Werner LEMBERG <wl>
Group administrator
Thu 23 Feb 2012 12:09:12 PM UTC, original submission:  

Crash tested with ftbench, compiled under Ubuntu amd64 with AddressSanitizer (http://code.google.com/p/address-sanitizer/).

Log from ASAN build:

=================================================================
==27332== ERROR: AddressSanitizer heap-buffer-overflow on address 0x7f4855c75480 at pc 0x5c51cf bp 0x7fff0b33e520 sp 0x7fff0b33e508
READ of size 1 at 0x7f4855c75480 thread T0
  #0 0x5c51cf strlen
  #1 0x4a3384 ft_mem_strdup
  #2 0x56f434 _bdf_add_property
  #3 0x56e0fd _bdf_parse_properties
  #4 0x56a876 _bdf_readstream
  #5 0x568a19 bdf_load_font
  #6 0x565aad BDF_Face_Init
  #7 0x4913e0 open_face
  #8 0x4909a3 FT_Open_Face
  #9 0x48fd06 FT_New_Face
  #10 0x487557 get_face
  #11 0x487cb1 main
  #12 0x7f48568c9d5d __libc_start_main
0x7f4855c75480 is located 0 bytes to the right of 1024-byte region [0x7f4855c75080,0x7f4855c75480)
allocated by thread T0 here:
  #0 0x5c3222 malloc
  #1 0x4a0434 ft_mem_qalloc
  #2 0x48b3cf ft_mem_alloc
  #3 0x4a3012 ft_mem_qrealloc
  #4 0x48bccd ft_mem_realloc
  #5 0x56a6cd _bdf_readstream
  #6 0x568a19 bdf_load_font
  #7 0x565aad BDF_Face_Init
  #8 0x4913e0 open_face
  #9 0x4909a3 FT_Open_Face
  #10 0x48fd06 FT_New_Face
  #11 0x487557 get_face
  #12 0x487cb1 main
  #13 0x7f48568c9d5d __libc_start_main
==27332== ABORTING
Stats: 0M malloced (0M for red zones) by 814 calls
Stats: 0M realloced by 4 calls
Stats: 0M freed by 32 calls
Stats: 0M really freed by 0 calls
Stats: 32M (8196 full pages) mmaped in 8 calls
  mmaps   by size class: 8:16383; 9:8191; 10:4095; 11:2047; 12:1024; 13:512; 15:128; 16:64;
  mallocs by size class: 8:774; 9:20; 10:7; 11:6; 12:3; 13:1; 15:2; 16:1;
  frees   by size class: 8:19; 9:3; 10:6; 11:2; 12:1; 13:1;
  rfrees  by size class:
Stats: malloc large: 0 small slow: 9
Shadow byte and word:
  0x1fe90ab8ea90: fa
  0x1fe90ab8ea90: fa fa fa fa fa fa fa fa
More shadow bytes:
  0x1fe90ab8ea70: 00 00 00 00 00 00 00 00
  0x1fe90ab8ea78: 00 00 00 00 00 00 00 00
  0x1fe90ab8ea80: 00 00 00 00 00 00 00 00
  0x1fe90ab8ea88: 00 00 00 00 00 00 00 00
=>0x1fe90ab8ea90: fa fa fa fa fa fa fa fa
  0x1fe90ab8ea98: fa fa fa fa fa fa fa fa
  0x1fe90ab8eaa0: fa fa fa fa fa fa fa fa
  0x1fe90ab8eaa8: fa fa fa fa fa fa fa fa
  0x1fe90ab8eab0: fa fa fa fa fa fa fa fa


Log from Valgrind:

==27446== Memcheck, a memory error detector
==27446== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==27446== Using Valgrind-3.8.0.SVN and LibVEX; rerun with -h for copyright info
==27446== Command: ./a.out /tmp/freetype/01-devnag18.bdf.asan.5f.0
==27446==
==27446== Invalid read of size 1
==27446==    at 0x4C2C464: __GI_strlen (memcheck/mc_replace_strmem.c:391)
==27446==    by 0x407C1A: ft_mem_strdup (freetype2/freetype-2.4.8/src/base/ftutil.c:198)
==27446==    by 0x433985: _bdf_add_property (freetype2/freetype-2.4.8/src/bdf/bdflib.c:1364)
==27446==    by 0x433C06: _bdf_parse_properties (freetype2/freetype-2.4.8/src/bdf/bdflib.c:1964)
==27446==    by 0x433000: BDF_Face_Init (freetype2/freetype-2.4.8/src/bdf/bdflib.c:722)
==27446==    by 0x4089B7: open_face (freetype2/freetype-2.4.8/src/base/ftobjs.c:1149)
==27446==    by 0x40B362: FT_Open_Face (freetype2/freetype-2.4.8/src/base/ftobjs.c:2076)
==27446==    by 0x40C58A: FT_New_Face (freetype2/freetype-2.4.8/src/base/ftobjs.c:1211)
==27446==    by 0x40235C: get_face (freetype2/ft2demos-2.4.8/src/ftbench.c:624)
==27446==    by 0x402660: main (freetype2/ft2demos-2.4.8/src/ftbench.c:752)
==27446==  Address 0x53dc780 is 0 bytes after a block of size 1,024 alloc'd
==27446==    at 0x4C2A4D6: malloc (/coregrind/m_replacemalloc/vg_replace_malloc.c:263)
==27446==    by 0x406CBF: ft_mem_qalloc (freetype2/freetype-2.4.8/src/base/ftutil.c:76)
==27446==    by 0x4082D2: ft_mem_alloc (freetype2/freetype-2.4.8/src/base/ftutil.c:55)
==27446==    by 0x408404: ft_mem_qrealloc (freetype2/freetype-2.4.8/src/base/ftutil.c:145)
==27446==    by 0x408CCA: ft_mem_realloc (freetype2/freetype-2.4.8/src/base/ftutil.c:101)
==27446==    by 0x4326A1: BDF_Face_Init (freetype2/freetype-2.4.8/src/bdf/bdflib.c:634)
==27446==    by 0x4089B7: open_face (freetype2/freetype-2.4.8/src/base/ftobjs.c:1149)
==27446==    by 0x40B362: FT_Open_Face (freetype2/freetype-2.4.8/src/base/ftobjs.c:2076)
==27446==    by 0x40C58A: FT_New_Face (freetype2/freetype-2.4.8/src/base/ftobjs.c:1211)
==27446==    by 0x40235C: get_face (freetype2/ft2demos-2.4.8/src/ftbench.c:624)
==27446==    by 0x402660: main (freetype2/ft2demos-2.4.8/src/ftbench.c:752)
==27446==
==27446== Invalid read of size 1
==27446==    at 0x4C2D28C: memcpy (memcheck/mc_replace_strmem.c:838)
==27446==    by 0x407BE1: ft_mem_dup (/usr/include/bits/string3.h:52)
==27446==    by 0x433985: _bdf_add_property (freetype2/freetype-2.4.8/src/bdf/bdflib.c:1364)
==27446==    by 0x433C06: _bdf_parse_properties (freetype2/freetype-2.4.8/src/bdf/bdflib.c:1964)
==27446==    by 0x433000: BDF_Face_Init (freetype2/freetype-2.4.8/src/bdf/bdflib.c:722)
==27446==    by 0x4089B7: open_face (freetype2/freetype-2.4.8/src/base/ftobjs.c:1149)
==27446==    by 0x40B362: FT_Open_Face (freetype2/freetype-2.4.8/src/base/ftobjs.c:2076)
==27446==    by 0x40C58A: FT_New_Face (freetype2/freetype-2.4.8/src/base/ftobjs.c:1211)
==27446==    by 0x40235C: get_face (freetype2/ft2demos-2.4.8/src/ftbench.c:624)
==27446==    by 0x402660: main (freetype2/ft2demos-2.4.8/src/ftbench.c:752)
==27446==  Address 0x53dc780 is 0 bytes after a block of size 1,024 alloc'd
==27446==    at 0x4C2A4D6: malloc (/coregrind/m_replacemalloc/vg_replace_malloc.c:263)
==27446==    by 0x406CBF: ft_mem_qalloc (freetype2/freetype-2.4.8/src/base/ftutil.c:76)
==27446==    by 0x4082D2: ft_mem_alloc (freetype2/freetype-2.4.8/src/base/ftutil.c:55)
==27446==    by 0x408404: ft_mem_qrealloc (freetype2/freetype-2.4.8/src/base/ftutil.c:145)
==27446==    by 0x408CCA: ft_mem_realloc (freetype2/freetype-2.4.8/src/base/ftutil.c:101)
==27446==    by 0x4326A1: BDF_Face_Init (freetype2/freetype-2.4.8/src/bdf/bdflib.c:634)
==27446==    by 0x4089B7: open_face (freetype2/freetype-2.4.8/src/base/ftobjs.c:1149)
==27446==    by 0x40B362: FT_Open_Face (freetype2/freetype-2.4.8/src/base/ftobjs.c:2076)
==27446==    by 0x40C58A: FT_New_Face (freetype2/freetype-2.4.8/src/base/ftobjs.c:1211)
==27446==    by 0x40235C: get_face (freetype2/ft2demos-2.4.8/src/ftbench.c:624)
==27446==    by 0x402660: main (freetype2/ft2demos-2.4.8/src/ftbench.c:752)
==27446==
couldn't load font resource
==27446==
==27446== HEAP SUMMARY:
==27446==     in use at exit: 0 bytes in 0 blocks
==27446==   total heap usage: 207 allocs, 207 frees, 108,599 bytes allocated
==27446==
==27446== All heap blocks were freed -- no leaks are possible
==27446==
==27446== For counts of detected and suppressed errors, rerun with: -v
==27446== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 4 from 4)

Mateusz Jurczyk <j00ru>
Group Member

 

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

Attached Files
file #25129:  01-devnag18.bdf.asan.5f.0 added by j00ru (30KiB - 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 wl (Updated the item)
  • -email is unavailable- added by j00ru (Submitted the item)
  • -email is unavailable- added by j00ru
  •  

    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 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-02-26 wl StatusNone Fixed
        PrivacyPrivate Public
        Open/ClosedOpen Closed
        Planned ReleaseNone 2.4.9
    2012-02-25 wl Assigned toNone wl
    2012-02-23 j00ru Attached File- Added 01-devnag18.bdf.asan.5f.0, #25129
        Carbon-Copy- Added j00ru

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code