bug-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug classpath/26312] New: ChunkedInputStream..read() returns incorrect


From: daney at gcc dot gnu dot org
Subject: [Bug classpath/26312] New: ChunkedInputStream..read() returns incorrect values.
Date: 16 Feb 2006 04:54:51 -0000

Look at the code below, if the high bit in the byte is set read returns a
negitive number.  The is clearly in violation of the specification which says
the value must be between 0 - 255.


85 :         public int read() 
86 :           throws IOException 
87 :         { 
88 :           byte[] buf = new byte[1]; 
89 :           int len = read(buf, 0, 1); 
90 :           if (len == -1) 
91 :             { 
92 :               return -1; 
93 :             } 
94 :           int ret = (int) buf[0]; 
95 :           if (ret < 0) 
96 :             { 
97 :               ret += 0x100; 
98 :             } 
99 :           return ret; 
100 :         } 

Lines 94-99 should be replaced with: return 0xff & buf[0];


-- 
           Summary: ChunkedInputStream..read() returns incorrect values.
           Product: classpath
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: classpath
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: daney at gcc dot gnu dot org
 GCC build triplet: *-*-*
  GCC host triplet: *-*-*
GCC target triplet: *-*-*


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26312





reply via email to

[Prev in Thread] Current Thread [Next in Thread]