Bug 47225

Summary: Wrong argument in redirectPath.setChars in Mapper.internalMapWrapper()
Product: Tomcat 5 Reporter: Konstantin Kolinko <knst.kolinko>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: minor    
Priority: P2    
Version: 5.5.28   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   

Description Konstantin Kolinko 2009-05-19 21:52:39 UTC
Found in current trunk and tc6.0.x, and tc5.5.x:

http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/http/mapper/Mapper.java?annotate=734728&pathrev=770809

730 : 	  	  	 if(mappingData.wrapper == null && noServletPath) {
731 : 	  	  	// The path is empty, redirect to "/"
732 : 	  	  	mappingData.redirectPath.setChars
733 : 	  	  	(path.getBuffer(), pathOffset, pathEnd);
734 : 	  	  	path.setEnd(pathEnd - 1);
735 : 	  	  	return;
736 : 	  	  	}

On line 733 the pathEnd argument is wrong:
it should be length, not an index.

It should be
 mappingData.redirectPath.setChars(path.getBuffer(), pathOffset, pathEnd-pathOffset);

Do not know, why there are no complaints. May be pathOffset is always zero?
Comment 1 Mark Thomas 2009-09-16 14:24:04 UTC
I'd guess pathOffset is (nearly) always zero. I have fixed it in trunk and proposed it for 6.0.x and 5.5.x
Comment 2 Mark Thomas 2009-09-27 10:23:58 UTC
This has been fixed in 6.0.x and will be included in 6.0.21 onwards.
Comment 3 Mark Thomas 2009-10-03 09:24:58 UTC
This has been fixed in 5.5.x and will be included in 5.5.29 onwards.