changeset 3811:b853414b8eef

6702400: ChunkedInputStream expecting -1 from int read, but int->char comparision is wrong Reviewed-by: chegar
author michaelm
date Tue, 22 Feb 2011 14:44:43 +0000
parents bac152c6491a
children 75216854fb53
files src/share/classes/sun/net/httpserver/ChunkedInputStream.java
diffstat 1 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/net/httpserver/ChunkedInputStream.java	Tue Feb 22 14:28:13 2011 +0000
+++ b/src/share/classes/sun/net/httpserver/ChunkedInputStream.java	Tue Feb 22 14:44:43 2011 +0000
@@ -69,32 +69,33 @@
      */
     private int readChunkHeader () throws IOException {
         boolean gotCR = false;
-        char c;
+        int c;
         char[] len_arr = new char [16];
         int len_size = 0;
         boolean end_of_len = false;
 
-        while ((c=(char)in.read())!= -1) {
+        while ((c=in.read())!= -1) {
+            char ch = (char) c;
             if (len_size == len_arr.length -1) {
                 throw new IOException ("invalid chunk header");
             }
             if (gotCR) {
-                if (c == LF) {
+                if (ch == LF) {
                     int l = numeric (len_arr, len_size);
                     return l;
                 } else {
                     gotCR = false;
                 }
                 if (!end_of_len) {
-                    len_arr[len_size++] = c;
+                    len_arr[len_size++] = ch;
                 }
             } else {
-                if (c == CR) {
+                if (ch == CR) {
                     gotCR = true;
-                } else if (c == ';') {
+                } else if (ch == ';') {
                     end_of_len = true;
                 } else if (!end_of_len) {
-                    len_arr[len_size++] = c;
+                    len_arr[len_size++] = ch;
                 }
             }
         }