tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 30870] New: - Endless loop in Cookies.processCookies
Date Thu, 26 Aug 2004 15:54:12 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=30870>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=30870

Endless loop in Cookies.processCookies

           Summary: Endless loop in Cookies.processCookies
           Product: Tomcat 4
           Version: 4.1.24
          Platform: All
        OS/Version: Other
            Status: NEW
          Severity: Critical
          Priority: Other
         Component: Unknown
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: tony.perkins@sabre.com


If cookieValue (indicated at >>>) is null the code will continue in an endless
loop. This has caused two of our servers to go to 99% cpu on the tomcat process.

 public  void processCookies( MimeHeaders headers ) {
	if( headers==null )
	    return;// nothing to process
	// process each "cookie" header
	int pos=0;
	while( pos>=0 ) {
	    // Cookie2: version ? not needed
	    pos=headers.findHeader( "Cookie", pos );
	    // no more cookie headers headers
	    if( pos<0 ) break;

>>>	    MessageBytes cookieValue=headers.getValue( pos );
	    if( cookieValue==null || cookieValue.isNull() ) continue;

	    // Uncomment to test the new parsing code
	    if( cookieValue.getType() == MessageBytes.T_BYTES ) {
		if( dbg>0 ) log( "Parsing b[]: " + cookieValue.toString());
		ByteChunk bc=cookieValue.getByteChunk();
		processCookieHeader( bc.getBytes(),
				     bc.getOffset(),
				     bc.getLength());
	    } else {
		if( dbg>0 ) log( "Parsing S: " + cookieValue.toString());
		processCookieHeader( cookieValue.toString() );
	    }
	    pos++;// search from the next position
	}
    }


Should be something like:

if( cookieValue==null || cookieValue.isNull() ){
  pos++;
  continue;
}

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message