Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0005807 [Resin] minor always 10-01-14 17:24 10-01-14 17:24
Reporter nam View Status public  
Assigned To nam
Priority normal Resolution fixed  
Status closed   Product Version 4.0.41
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')) {
Additional Information
Attached Files

- Relationships

- Notes
(0006533)
nam
10-01-14 17:24

server/05ac

Fixed for 4.0.42.
 

- Issue History
Date Modified Username Field Change
10-01-14 17:24 nam New Issue
10-01-14 17:24 nam Status new => assigned
10-01-14 17:24 nam Assigned To  => nam
10-01-14 17:24 nam Status assigned => closed
10-01-14 17:24 nam Note Added: 0006533
10-01-14 17:24 nam Resolution open => fixed


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
28 total queries executed.
25 unique queries executed.
Powered by Mantis Bugtracker