freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][master] [pfr] Fortify the kerning code.


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype][master] [pfr] Fortify the kerning code.
Date: Tue, 26 Jul 2022 16:34:28 +0000

Alexei Podtelezhnikov pushed to branch master at FreeType / FreeType

Commits:

  • 284956b5
    by Alexei Podtelezhnikov at 2022-07-26T12:23:15-04:00
    [pfr] Fortify the kerning code.
    
    Any array index must be strictly less then the array size. Therefore,
    we must reject indexes that are equal to the array size.  Alternatively,
    we should move the bounds check before the index decrement but that
    would be confusing.
    
    In addition, it is ok to decrement zero (.notdef) and get UINT_MAX,
    which is then automatically rejected in the bounds check.
    
    * src/pfr/pfrobjs.c (pfr_face_get_kerning): Fix the bounds checking.
    

1 changed file:

Changes:

  • src/pfr/pfrobjs.c
    ... ... @@ -486,17 +486,16 @@
    486 486
         kerning->x = 0;
    
    487 487
         kerning->y = 0;
    
    488 488
     
    
    489
    -    if ( glyph1 > 0 )
    
    490
    -      glyph1--;
    
    489
    +    /* PFR indexing skips .notdef, which becomes UINT_MAX */
    
    490
    +    glyph1--;
    
    491
    +    glyph2--;
    
    491 492
     
    
    492
    -    if ( glyph2 > 0 )
    
    493
    -      glyph2--;
    
    494
    -
    
    495
    -    /* convert glyph indices to character codes */
    
    496
    -    if ( glyph1 > phy_font->num_chars ||
    
    497
    -         glyph2 > phy_font->num_chars )
    
    493
    +    /* check the array bounds, .notdef is automacally out */
    
    494
    +    if ( glyph1 >= phy_font->num_chars ||
    
    495
    +         glyph2 >= phy_font->num_chars )
    
    498 496
           goto Exit;
    
    499 497
     
    
    498
    +    /* convert glyph indices to character codes */
    
    500 499
         code1 = phy_font->chars[glyph1].char_code;
    
    501 500
         code2 = phy_font->chars[glyph2].char_code;
    
    502 501
         pair  = PFR_KERN_INDEX( code1, code2 );
    


  • reply via email to

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