freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Git][freetype/freetype][master] Avoid overflow in COLR bounds checks.


From: Ben Wagner (@bungeman)
Subject: [Git][freetype/freetype][master] Avoid overflow in COLR bounds checks.
Date: Fri, 04 Aug 2023 18:24:25 +0000

Ben Wagner pushed to branch master at FreeType / FreeType

Commits:

  • 3829fdaa
    by Ben Wagner at 2023-08-04T11:41:23-04:00
    Avoid overflow in COLR bounds checks.
    
    The values read into `base_glyphs_offset_v1` and `layer_offset_v1` may
    be in the range 0xFFFFFFFD-0xFFFFFFFF. On systems where `unsigned long`
    is 32 bits adding 4 to such values will wrap and pass bounds checks but
    accessing values at such offsets will be out of bounds.
    
    On the other hand `table_size` has already been tested to be at least
    `COLRV1_HEADER_SIZE` (34) so it is safe to subtract 4 from it.
    
    * src/sfnt/ttcolr.c (tt_face_load_colr): subtract 4 from `table_size`
    instead of adding 4 to font data offsets in bounds checks
    
    Fixes: https://crbug.com/1469348
    

1 changed file:

Changes:

  • src/sfnt/ttcolr.c
    ... ... @@ -229,7 +229,7 @@
    229 229
     
    
    230 230
           base_glyphs_offset_v1 = FT_NEXT_ULONG( p );
    
    231 231
     
    
    232
    -      if ( base_glyphs_offset_v1 + 4 >= table_size )
    
    232
    +      if ( base_glyphs_offset_v1 >= table_size - 4 )
    
    233 233
             goto InvalidTable;
    
    234 234
     
    
    235 235
           p1                 = (FT_Byte*)( table + base_glyphs_offset_v1 );
    
    ... ... @@ -249,7 +249,7 @@
    249 249
     
    
    250 250
           if ( layer_offset_v1 )
    
    251 251
           {
    
    252
    -        if ( layer_offset_v1 + 4 >= table_size )
    
    252
    +        if ( layer_offset_v1 >= table_size - 4 )
    
    253 253
               goto InvalidTable;
    
    254 254
     
    
    255 255
             p1            = (FT_Byte*)( table + layer_offset_v1 );
    


  • reply via email to

    [Prev in Thread] Current Thread [Next in Thread]