bugThe FreeType Project - Bugs: bug #45965, src/truetype/ttobjs.c:204:46:...

 
 

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

bug #45965: src/truetype/ttobjs.c:204:46: runtime error: left shift of 184 by 24 places cannot be represented in type 'int'

Submitter:  Kostya Serebryany <kcc>
Submitted:  Mon 14 Sep 2015 09:19:09 PM UTC
   
 
Severity:  3 - Normal Item Group:  None
Status:  Fixed Privacy:  Public
Assigned to:  wl Open/Closed:  Closed
Planned Release:  2.6.1

Tue 15 Sep 2015 05:36:29 AM UTC, comment #2: 

fix confirmed, thanks!
I agree that this is a minor bug and I don't know a compiler
that would miscompile this.
OTOH, I've seen things done by compilers I wouldn't believe they could do (and still within the standard)

Kostya Serebryany <kcc>
Group Member
Tue 15 Sep 2015 05:31:13 AM UTC, comment #1: 

Fixed in git, I hope.  Please test.

Note that FT_GET_BYTE already returns an unsigned value.  The problem is that `i' was a signed type, making the whole expression treated as signed before cast to `FT_UInt32'.

[BTW, this issue is a non-bug, I think: AFAIK, compilers handle such situations gracefully, doing the shift regardless of signed vs. unsigned issues.]

Werner LEMBERG <wl>
Group administrator
Mon 14 Sep 2015 09:19:09 PM UTC, original submission:  

found on fresh git with libFuzzer+UBsan (on x86_64 Linux)

Build with -fsanitize=shift and feed the attached file into FT_New_Memory_Face


src/truetype/ttobjs.c:204:46: runtime error: left shift of 184 by 24 places cannot be represented in type 'int'

The code is:
      checksum += (FT_UInt32)( FT_GET_BYTE() << ( i * 8 ) );

Probably, FT_GET_BYTE() needs to be cast to unsigned before
the shift.

Kostya Serebryany <kcc>
Group Member

 

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

Attached Files
file #34882:  fc5a5d956829d98f6f6ea5c7b393df39e38616f7 added by kcc (8KiB - 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 (Posted a comment)
  • -email is unavailable- added by kcc (Submitted the item)
  • -email is unavailable- added by kcc
  •  

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

    Date Changed by Updated Field Previous Value => Replaced by
    2015-09-15 wl StatusNone Fixed
        Assigned toNone wl
        Open/ClosedOpen Closed
        Planned ReleaseNone 2.6.1
    2015-09-14 kcc Attached File- Added fc5a5d956829d98f6f6ea5c7b393df39e38616f7, #34882
        Carbon-Copy- Added j00ru

    Back to the top

    Powered by Savane 3.14-f13d.
    Corresponding source code