bugThe FreeType Project - Bugs: bug #58275, Compiler warnings when building...

 
 

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

bug #58275: Compiler warnings when building utilities in ft2demos

Submitter:  None
Submitted:  Wed 29 Apr 2020 11:17:41 PM UTC
   
 
Severity:  3 - Normal Item Group:  Incorrect behaviour
Status:  Fixed Privacy:  Public
Assigned to:  freetype Open/Closed:  Closed
Planned Release:  2.10.2

Mon 11 May 2020 02:40:19 AM UTC, comment #2: 

strncat also generates -Wstringop-truncation warnings. It is numm-terminated so I do not understand why. 

In function ‘Cur_U_Line’,
    inlined from ‘RunIns’ at /home/apodtele/freetype2-demos/src/ttdebug.c:2105:11:
/home/apodtele/freetype2-demos/src/ttdebug.c:1756:7: warning: ‘strncat’ output may be truncated copying 31 bytes from a string of length 31 [-Wstringop-truncation]
 1756 |       strncat( tempStr, s, 31 );
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/apodtele/freetype2-demos/src/ttdebug.c:1750:9: warning: ‘strncat’ output may be truncated copying 8 bytes from a string of length 31 [-Wstringop-truncation]
 1750 |         strncat( tempStr, s, 8 );
      |         ^~~~~~~~~~~~~~~~~~~~~~~~
/home/apodtele/freetype2-demos/src/ttdebug.c:1727:9: warning: ‘strncat’ output may be truncated copying 8 bytes from a string of length 31 [-Wstringop-truncation]
 1727 |         strncat( tempStr, s, 8 );
      |         ^~~~~~~~~~~~~~~~~~~~~~~~
/home/apodtele/freetype2-demos/src/ttdebug.c:1691:7: warning: ‘strncat’ output may be truncated copying 8 bytes from a string of length 31 [-Wstringop-truncation]
 1691 |       strncat( tempStr, s, 8 );
      |       ^~~~~~~~~~~~~~~~~~~~~~~~
/home/apodtele/freetype2-demos/src/ttdebug.c:1713:9: warning: ‘strncat’ output may be truncated copying 8 bytes from a string of length 31 [-Wstringop-truncation]
 1713 |         strncat( tempStr, s, 8 );
      |         ^~~~~~~~~~~~~~~~~~~~~~~~
/home/apodtele/freetype2-demos/src/ttdebug.c:1671:7: warning: ‘strncat’ output may be truncated copying 8 bytes from a string of length 31 [-Wstringop-truncation]
 1671 |       strncat( tempStr, s, 8 );
      |       ^~~~~~~~~~~~~~~~~~~~~~~~
/home/apodtele/freetype2-demos/src/ttdebug.c:1684:9: warning: ‘strncat’ output may be truncated copying 8 bytes from a string of length 31 [-Wstringop-truncation]
 1684 |         strncat( tempStr, s, 8 );
      |         ^~~~~~~~~~~~~~~~~~~~~~~~

Alexei Podtelezhnikov <podtelez>
Group Member
Fri 01 May 2020 01:19:28 PM UTC, comment #1: 

Fixed in git, thanks.

Werner LEMBERG <wl>
Group administrator
Wed 29 Apr 2020 11:17:41 PM UTC, original submission:  

Good afternoon,

 

When building FreeType, GCC is warning of strncpy() calls which are not nul terminated.

Probably not a big problem in view of the context.

 

Example :

 

src/ftchkwd.c:172:9: warning: 'strncpy' output truncated before terminating nul

copying 4 bytes from a string of the same length [-Wstringop-truncation]

         strncpy( filename + strlen( filename ), ".ttf", 4 );

         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/ftchkwd.c:173:9: warning: 'strncpy' output truncated before terminating nul

copying 4 bytes from a string of the same length [-Wstringop-truncation]

         strncpy( alt_filename + strlen( alt_filename ), ".ttc", 4 );

         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

There are 8 source files using the same code sequence to append “.ttf” or “.ttc” to filenames.

Two of them (ftdump.c, ftlint.c) will copy the nul (5th byte).

Six do not (compos.c, ftchkwd.c, ftmemchk.c, ftsbit.c, fttimer.c, fttry.c).

 

 

# grepall '\.ttf' | grep 'strncpy.*4'                         

./ft2demos-2.10.1/src/compos.c:102:        strncpy( filename + strlen( filename ), ".ttf", 4 );

./ft2demos-2.10.1/src/ftchkwd.c:172:        strncpy( filename + strlen( filename ), ".ttf", 4 );

./ft2demos-2.10.1/src/ftmemchk.c:273:        strncpy( filename + strlen( filename ), ".ttf", 4 );

./ft2demos-2.10.1/src/ftsbit.c:206:      strncpy( filename + strlen( filename ), ".ttf", 4 );

./ft2demos-2.10.1/src/fttimer.c:233:      strncpy( filename + strlen( filename ), ".ttf", 4 );

./ft2demos-2.10.1/src/fttry.c:119:        strncpy( filename + strlen( filename ), ".ttf", 4 );

 

 

Thanks.

 

Mike Wilson

Anonymous

 

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

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by podtelez (Posted a comment)
  • -email is unavailable- added by wl (Posted a comment)
  •  

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

    Date Changed by Updated Field Previous Value => Replaced by
    2020-05-01 wl StatusNone Fixed
        Assigned toNone freetype
        Open/ClosedOpen Closed
        Planned ReleaseNone 2.10.2

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code