|
Mantis - Resin
|
|||||
| Viewing Issue Advanced Details | |||||
|
|
|||||
| ID: | Category: | Severity: | Reproducibility: | Date Submitted: | Last Update: |
| 5807 | minor | always | 10-01-14 17:24 | 10-01-14 17:24 | |
|
|
|||||
| Reporter: | nam | Platform: | |||
| Assigned To: | nam | OS: | |||
| Priority: | normal | OS Version: | |||
| Status: | closed | Product Version: | 4.0.41 | ||
| Product Build: | Resolution: | fixed | |||
| Projection: | none | ||||
| ETA: | none | Fixed in Version: | |||
|
|
|||||
| Summary: | 0005807: AbstractHttpResponse.setHeader(-1) throws IllegalArgumentException | ||||
| Description: |
(rep by stegard) This works fine: response.setContentLength(-1); However, we are encountering a Resin exception when the following is called: response.setHeader("Content-Length", "-1"); (IllegalArgumentException with message "-1 is an invalid content-length".) Looks like AbstractHttpResponse#parseLong has an error in it with numbers prefixed with either "+" or "-". Propose the following patch (Resin 4.0.41): --- AbstractHttpResponse.java.orig 2014-10-01 22:47:03.133607270 +0200 +++ AbstractHttpResponse.java 2014-10-01 22:47:30.241607757 +0200 @@ -572,11 +572,11 @@ sign = -1; if (i < length) - ch = string.charAt(i++); + ch = string.charAt(++i); } else if (ch == '+') { if (i < length) - ch = string.charAt(i++); + ch = string.charAt(++i); } if (! ('0' <= ch && ch <= '9')) { ---------------------------------------------------- Added checks to avoid going out of bounds on invalid number input: --- AbstractHttpResponse.java.orig 2014-10-01 22:47:03.133607270 +0200 +++ AbstractHttpResponse.java 2014-10-01 23:06:58.209628739 +0200 @@ -571,12 +571,12 @@ if (ch == '-') { sign = -1; - if (i < length) - ch = string.charAt(i++); + if (i < length-1) + ch = string.charAt(++i); } else if (ch == '+') { - if (i < length) - ch = string.charAt(i++); + if (i < length-1) + ch = string.charAt(++i); } if (! ('0' <= ch && ch <= '9')) { |
||||
| Steps To Reproduce: | |||||
| Additional Information: | |||||
| Relationships | |||||
| Attached Files: | |||||
| Notes | |||||
|
|
|||||
|
|
||||