bugThe FreeType Project - Bugs: bug #24468, Improper Cast of *FT_UInt32 to...

 
 

bug #24468: Improper Cast of *FT_UInt32 to *FT_UInt causing problems

Submitted by:  None
Submitted on:  Mon 06 Oct 2008 06:07:48 PM UTC  
 
Severity: 3 - NormalItem Group: Incorrect behaviour
Status: FixedPrivacy: Public
Assigned to: suzuki toshiya <mpsuzuki>Open/Closed: Closed
Planned Release: 2.3.8

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Thu 09 Oct 2008 05:54:00 AM UTC, comment #2:

Although I don't have genuine 16bit SDK, legacy
metrowerks C compiler reports similar warnings.
Attached patch will fix the problem, it is applied
to CVS HEAD on 2008-10-09. Please check.

(file #16634)

suzuki toshiya <mpsuzuki>
Project AdministratorIn charge of this item.
Mon 06 Oct 2008 08:27:01 PM UTC, comment #1:

We haven't tested FreeType with a 16bit compiler for a longer time; some of the code has been added after that.

Can you provide patches? And please continue with testing and report problems! I'm quite certain more errors will follow (which are hopefully easy to catch and fix).

Werner LEMBERG <wl>
Project Administrator
Mon 06 Oct 2008 06:07:48 PM UTC, original submission:

In "ttcmap.c" (within FreeType 2.3.7) there are several instances of pointer to FT_UInt32 being cast as a *FT_UInt.
This is a problem in porting this to a machine with big endian 16 bit ints (in my case Renesas H8SX).
By taking a pointer to 32 bit big endian data and accessing this via 16 bit pointer, you are actually accessing the upper 16 bits of the 32 bit data.

While very poor practice, this will work in little endian machines or machines where int is 32 bits.

In some cases, the a FT_Uint is being assigned to FT_UInt32...here data is being accessed beyond the allocated space...this doesn't work in my system, nor would I expect it to work on any system where int is not 32bits.

Specific instances are:
tt_cmap4_char_index( TT_CMap cmap, FT_UInt32 char_code )
...
return tt_cmap4_char_map_linear( cmap, &char_code, 0 );
...
return tt_cmap4_char_map_binary( cmap, &char_code, 0 );

tt_cmap4_char_next( TT_CMap cmap, FT_UInt32 *pchar_code )
...
gindex = tt_cmap4_char_map_linear( cmap, pchar_code, 1 );
...
gindex = tt_cmap4_char_map_binary( cmap, pchar_code, 1 );

static FT_UInt*
tt_cmap14_get_nondef_chars( TT_CMap cmap,
FT_Byte *p,
FT_Memory memory )
FT_UInt32 *ret;
return ret;

FT_CALLBACK_DEF( FT_UInt32 * )
tt_cmap14_variant_chars( TT_CMap cmap,
FT_Memory memory,
FT_ULong variantSelector )
...
return tt_cmap14_get_nondef_chars( cmap, cmap->data +
...
return tt_cmap14_get_nondef_chars( cmap, cmap->data +

Anonymous

 

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

Attach File(s):
   
   
Comment:
   

Attached Files

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by mpsuzuki (Updated the item)
  • -unavailable- added by wl (Posted a comment)
  • -unavailable- added by jmbraben (Bug Originator)
  •  

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

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 09 Oct 2008 05:54:00 AM UTCmpsuzukiAttached File-=>Added ft2-cwide17_20081009a.patch, #16634
      StatusConfirmed=>Fixed
      Assigned towl=>mpsuzuki
      Open/ClosedOpen=>Closed
      Planned ReleaseNone=>2.3.8
    Mon 06 Oct 2008 08:27:01 PM UTCwlStatusNone=>Confirmed
      Assigned toNone=>wl
    Mon 06 Oct 2008 06:15:00 PM UTCjmbrabenCarbon-Copy-=>Added -unavailable-

    Back to the top


    Powered by Savane 3.1-cleanup1