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

 
 

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

Submitted by:  Kostya Serebryany <kcc>
Submitted on:  Mon 14 Sep 2015 09:19:09 PM UTC  
 
Severity: 3 - NormalItem Group: None
Status: FixedPrivacy: Public
Assigned to: Werner LEMBERG <wl>Open/Closed: Closed
Planned Release: 2.6.1

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

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>
Project 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>
Project AdministratorIn charge of this item.
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>
Project Member

 

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

Attach File(s):
   
   
Comment:
   

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
  • -unavailable- added by wl (Posted a comment)
  • -unavailable- added by kcc (Submitted the item)
  • -unavailable- added by kcc
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 15 Sep 2015 05:31:13 AM UTCwlStatusNone=>Fixed
      Assigned toNone=>wl
      Open/ClosedOpen=>Closed
      Planned ReleaseNone=>2.6.1
    Mon 14 Sep 2015 09:19:09 PM UTCkccAttached File-=>Added fc5a5d956829d98f6f6ea5c7b393df39e38616f7, #34882
      Carbon-Copy-=>Added j00ru

    Back to the top


    Powered by Savane 3.1-cleanup1