DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=34097>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=34097

           Summary: TarInputStream.read() incorrectly returns signed values
           Product: Ant
           Version: 1.5.4
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: PatchAvailable
          Severity: normal
          Priority: P2
         Component: Core tasks
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


Implementations of InputStream.read() are supposed to return a single unsigned
byte of content (that is, an integer in the range of 0 to 255 representing a
single byte), or -1 in the event the end of the stream is reached. 
TarInputStream.read() returns these bytes signed (that is integer values in the
range of -128 to 127).  This causes too many problems to list, but most
obviously, causes some streams to be closed prematurely due to -1 being returned
as content instead of 255.  

Below is a simple fix.

--- TarInputStream.java Tue Jan 11 18:41:21 2005
+++ TarInputStream.java Sun Mar 20 22:27:50 2005
@@ -291,13 +291,13 @@
     public int read() throws IOException {
         int num = this.read(this.oneBuf, 0, 1);
 
         if (num == -1) {
             return num;
         } else {
-            return (int) this.oneBuf[0];
+            return (this.oneBuf[0] + 256) & 0xFF;
         }
     }

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to