[haiku-bugs] Re: [Haiku] #6599: fs_shell parse error during BuildHaikuImage

  • From: "zooey" <trac@xxxxxxxxxxxx>
  • Date: Sat, 18 Sep 2010 10:08:27 -0000

#6599: fs_shell parse error during BuildHaikuImage
--------------------------------+-------------------------------------------
  Reporter:  Disreali           |         Owner:  zooey         
      Type:  bug                |        Status:  assigned      
  Priority:  normal             |     Milestone:  R1            
 Component:  System/libroot.so  |       Version:  R1/Development
Resolution:                     |      Keywords:                
Blocked By:                     |   Has a Patch:  0             
  Platform:  All                |      Blocking:                
--------------------------------+-------------------------------------------

Comment (by zooey):

 Replying to [comment:15 bonefish]:
 > Replying to [comment:13 aldeck]:
 > > {{{
 > > char 'a'
 > > char 's'
 > > isspace (char = 0xffffffe2)
 > > isspace (char = 0xffffff80)
 > > isspace (char = 0xffffffa6)
 > > }}}
 > >
 > > which looks like the raw utf-8 inverted for the ellipsis: 0xE2 0x80
 0xA6
 >
 > I'd say the char is sign-extended to int.

 Yup, and I think the culprit is the isctype macro in ctype.h, which casts
 the given value to 'int' - it should cast the value to unsigned char
 instead, as otherwise any negative signed value will be extended
 inappropriately. Since the value is then used for an out-of-bounds access
 to ctype_b[], the outcome is undpredictable. The latter could explain
 different results for gcc4 and gcc2, additionally it could be that gcc2
 handles char types differently (maybe makes them signed by default?).

 If no-one beats me to it, I can fix this tomorrow.

-- 
Ticket URL: <http://dev.haiku-os.org/ticket/6599#comment:16>
Haiku <http://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: