freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][master] [bdf, cid, pfr, winfonts] Improve rejec


From: Werner Lemberg (@wl)
Subject: [Git][freetype/freetype][master] [bdf, cid, pfr, winfonts] Improve rejection of other font formats.
Date: Tue, 19 Oct 2021 21:22:02 +0000

Werner Lemberg pushed to branch master at FreeType / FreeType

Commits:

4 changed files:

Changes:

  • src/bdf/bdflib.c
    ... ... @@ -581,8 +581,14 @@
    581 581
           /* or even resizing it                                       */
    
    582 582
           if ( end >= avail )
    
    583 583
           {
    
    584
    -        if ( bytes == 0 )  /* last line in file doesn't end in \r or \n */
    
    585
    -          break;           /* ignore it then exit                       */
    
    584
    +        if ( bytes == 0 )
    
    585
    +        {
    
    586
    +          /* last line in file doesn't end in \r or \n; */
    
    587
    +          /* ignore it then exit                        */
    
    588
    +          if ( lineno == 1 )
    
    589
    +            error = FT_THROW( Missing_Startfont_Field );
    
    590
    +          break;
    
    591
    +        }
    
    586 592
     
    
    587 593
             if ( start == 0 )
    
    588 594
             {
    
    ... ... @@ -593,8 +599,13 @@
    593 599
     
    
    594 600
               if ( buf_size >= 65536UL )  /* limit ourselves to 64KByte */
    
    595 601
               {
    
    596
    -            FT_ERROR(( "_bdf_readstream: " ERRMSG6, lineno ));
    
    597
    -            error = FT_THROW( Invalid_Argument );
    
    602
    +            if ( lineno == 1 )
    
    603
    +              error = FT_THROW( Missing_Startfont_Field );
    
    604
    +            else
    
    605
    +            {
    
    606
    +              FT_ERROR(( "_bdf_readstream: " ERRMSG6, lineno ));
    
    607
    +              error = FT_THROW( Invalid_Argument );
    
    608
    +            }
    
    598 609
                 goto Exit;
    
    599 610
               }
    
    600 611
     
    
    ... ... @@ -2169,7 +2180,7 @@
    2169 2180
         unsigned long  lineno = 0; /* make compiler happy */
    
    2170 2181
         _bdf_parse_t   *p     = NULL;
    
    2171 2182
     
    
    2172
    -    FT_Error   error  = FT_Err_Ok;
    
    2183
    +    FT_Error  error = FT_Err_Ok;
    
    2173 2184
     
    
    2174 2185
     
    
    2175 2186
         if ( FT_NEW( p ) )
    

  • src/cid/cidparse.c
    ... ... @@ -73,7 +73,11 @@
    73 73
     
    
    74 74
         /* first of all, check the font format in the header */
    
    75 75
         if ( FT_FRAME_ENTER( 31 ) )
    
    76
    +    {
    
    77
    +      FT_TRACE2(( "  not a CID-keyed font\n" ));
    
    78
    +      error = FT_THROW( Unknown_File_Format );
    
    76 79
           goto Exit;
    
    80
    +    }
    
    77 81
     
    
    78 82
         if ( ft_strncmp( (char *)stream->cursor,
    
    79 83
                          "%!PS-Adobe-3.0 Resource-CIDFont", 31 ) )
    

  • src/pfr/pfrobjs.c
    ... ... @@ -83,7 +83,11 @@
    83 83
         /* load the header and check it */
    
    84 84
         error = pfr_header_load( &face->header, stream );
    
    85 85
         if ( error )
    
    86
    +    {
    
    87
    +      FT_TRACE2(( "  not a PFR font\n" ));
    
    88
    +      error = FT_THROW( Unknown_File_Format );
    
    86 89
           goto Exit;
    
    90
    +    }
    
    87 91
     
    
    88 92
         if ( !pfr_header_check( &face->header ) )
    
    89 93
         {
    

  • src/winfonts/winfnt.c
    ... ... @@ -217,7 +217,11 @@
    217 217
         /* first of all, read the FNT header */
    
    218 218
         if ( FT_STREAM_SEEK( font->offset )                        ||
    
    219 219
              FT_STREAM_READ_FIELDS( winfnt_header_fields, header ) )
    
    220
    +    {
    
    221
    +      FT_TRACE2(( "  not a Windows FNT file\n" ));
    
    222
    +      error = FT_THROW( Unknown_File_Format );
    
    220 223
           goto Exit;
    
    224
    +    }
    
    221 225
     
    
    222 226
         /* check header */
    
    223 227
         if ( header->version != 0x200 &&
    
    ... ... @@ -284,7 +288,10 @@
    284 288
         /* does it begin with an MZ header? */
    
    285 289
         if ( FT_STREAM_SEEK( 0 )                                      ||
    
    286 290
              FT_STREAM_READ_FIELDS( winmz_header_fields, &mz_header ) )
    
    291
    +    {
    
    292
    +      error = FT_ERR( Unknown_File_Format );
    
    287 293
           goto Exit;
    
    294
    +    }
    
    288 295
     
    
    289 296
         error = FT_ERR( Unknown_File_Format );
    
    290 297
         if ( mz_header.magic == WINFNT_MZ_MAGIC )
    


  • reply via email to

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