src/java.net.http/share/classes/jdk/internal/net/http/Http1HeaderParser.java
changeset 55392 444b2d3471e9
parent 50681 4254bed3c09d
--- a/src/java.net.http/share/classes/jdk/internal/net/http/Http1HeaderParser.java	Fri Jun 14 05:02:58 2019 +0000
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/Http1HeaderParser.java	Fri Jun 14 10:19:04 2019 +0530
@@ -194,7 +194,15 @@
         if (statusLine.length() < 12) {
             throw protocolException("Invalid status line: \"%s\"", statusLine);
         }
-        responseCode = Integer.parseInt(statusLine.substring(9, 12));
+        try {
+            responseCode = Integer.parseInt(statusLine.substring(9, 12));
+        } catch (NumberFormatException nfe) {
+            throw protocolException("Invalid status line: \"%s\"", statusLine);
+        }
+        // response code expected to be a 3-digit integer (RFC-2616, section 6.1.1)
+        if (responseCode < 100) {
+            throw protocolException("Invalid status line: \"%s\"", statusLine);
+        }
 
         state = State.STATUS_LINE_END;
     }