cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http Cookies.java
markt 2004/08/26 12:06:39 Modified:util/java/org/apache/tomcat/util/http Cookies.java Log: Tab police (prior to looking at bug 30870) Revision ChangesPath 1.8 +282 -274 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http/Cookies.java Index: Cookies.java === RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http/Cookies.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- Cookies.java 9 Aug 2004 23:23:43 - 1.7 +++ Cookies.java 26 Aug 2004 19:06:39 - 1.8 @@ -50,7 +50,7 @@ * information from the provided headers. */ public Cookies(MimeHeaders headers) { - this.headers=headers; +this.headers=headers; } /** @@ -80,12 +80,12 @@ * Recycle. */ public void recycle() { - for( int i=0; i cookieCount; i++ ) { - if( scookies[i]!=null ) - scookies[i].recycle(); - } - cookieCount=0; - unprocessed=true; +for( int i=0; i cookieCount; i++ ) { +if( scookies[i]!=null ) +scookies[i].recycle(); +} +cookieCount=0; +unprocessed=true; } /** @@ -105,18 +105,18 @@ // Indexed access public ServerCookie getCookie( int idx ) { - if( unprocessed ) { - getCookieCount(); // will also update the cookies - } - return scookies[idx]; +if( unprocessed ) { +getCookieCount(); // will also update the cookies +} +return scookies[idx]; } public int getCookieCount() { - if( unprocessed ) { - unprocessed=false; - processCookies(headers); - } - return cookieCount; +if( unprocessed ) { +unprocessed=false; +processCookies(headers); +} +return cookieCount; } // Adding cookies @@ -126,19 +126,19 @@ * The caller can set the name/value and attributes for the cookie */ public ServerCookie addCookie() { - if( cookieCount = scookies.length ) { - ServerCookie scookiesTmp[]=new ServerCookie[2*cookieCount]; - System.arraycopy( scookies, 0, scookiesTmp, 0, cookieCount); - scookies=scookiesTmp; - } - - ServerCookie c = scookies[cookieCount]; - if( c==null ) { - c= new ServerCookie(); - scookies[cookieCount]=c; - } - cookieCount++; - return c; +if( cookieCount = scookies.length ) { +ServerCookie scookiesTmp[]=new ServerCookie[2*cookieCount]; +System.arraycopy( scookies, 0, scookiesTmp, 0, cookieCount); +scookies=scookiesTmp; +} + +ServerCookie c = scookies[cookieCount]; +if( c==null ) { +c= new ServerCookie(); +scookies[cookieCount]=c; +} +cookieCount++; +return c; } @@ -147,32 +147,32 @@ /** Add all Cookie found in the headers of a request. */ 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( pos0 ) 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( dbg0 ) log( Parsing b[]: + cookieValue.toString()); - ByteChunk bc=cookieValue.getByteChunk(); - processCookieHeader( bc.getBytes(), - bc.getOffset(), - bc.getLength()); - } else { - if( dbg0 ) log( Parsing S: + cookieValue.toString()); - processCookieHeader( cookieValue.toString() ); - } - pos++;// search from the next position - } +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( pos0 ) break; + +MessageBytes cookieValue=headers.getValue( pos ); +if(
cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http Cookies.java
markt 2004/08/26 12:31:03 Modified:util/java/org/apache/tomcat/util/http Cookies.java Log: Fix bug 30870. Remove potential for endless loop in cookie processing. - Patch provided by Tony Perkins Revision ChangesPath 1.9 +4 -1 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http/Cookies.java Index: Cookies.java === RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http/Cookies.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- Cookies.java 26 Aug 2004 19:06:39 - 1.8 +++ Cookies.java 26 Aug 2004 19:31:03 - 1.9 @@ -158,7 +158,10 @@ if( pos0 ) break; MessageBytes cookieValue=headers.getValue( pos ); -if( cookieValue==null || cookieValue.isNull() ) continue; +if( cookieValue==null || cookieValue.isNull() ) { +pos++; +continue; +} // Uncomment to test the new parsing code if( cookieValue.getType() == MessageBytes.T_BYTES ) { - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http Cookies.java
luehe 2004/08/09 16:23:43 Modified:util/java/org/apache/tomcat/util/http Cookies.java Log: Avoid potential ArrayIndexOutOfBoundsException for something like Cookie: abc= We've been incrementing pos and later accessing cc=bytes[pos]; without checking for out-of-range, causing ArrayIndexOutOfBoundsException in some cases. Revision ChangesPath 1.7 +1 -1 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http/Cookies.java Index: Cookies.java === RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http/Cookies.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- Cookies.java 24 Feb 2004 08:50:04 - 1.6 +++ Cookies.java 9 Aug 2004 23:23:43 - 1.7 @@ -225,7 +225,7 @@ cc=bytes[pos]; pos++; - if( cc==';' || cc==',' ) { + if( cc==';' || cc==',' || pos=end ) { if( ! isSpecial startName!= endName ) { sc=addCookie(); sc.getName().setBytes( bytes, startName, - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http Cookies.java
luehe 2003/06/02 10:45:09 Modified:util/java/org/apache/tomcat/util/http Cookies.java Log: Fixed Bugtraq 4872647: RFC 2109 cookies with quoted values are not processed properly Patch provided by Ryan Lubke. Revision ChangesPath 1.4 +5 -4 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http/Cookies.java Index: Cookies.java === RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http/Cookies.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Cookies.java 17 Feb 2003 01:40:55 - 1.3 +++ Cookies.java 2 Jun 2003 17:45:09 - 1.4 @@ -231,6 +231,7 @@ int version=0; //sticky ServerCookie sc=null; + while( posend ) { byte cc; // [ skip_spaces name skip_spaces = skip_spaces value EXTRA ; ] * @@ -286,7 +287,7 @@ // quote is valid only in version=1 cookies cc=bytes[pos]; - if( version==1 ( cc== '\'' || cc=='' ) ) { + if( ( version == 1 || isSpecial ) ( cc== '\'' || cc=='' ) ) { startValue++; endValue=indexOf( bytes, startValue, end, cc ); pos=endValue+1; // to skip to next cookie @@ -470,7 +471,6 @@ } /* - public static void main( String args[] ) { test(foo=bar; a=b); test(foo=bar;a=b); @@ -480,7 +480,8 @@ test(foo=;a=b; ;); test(foo;a=b; ;); // v1 - test($Version=1; foo=bar;a=b); + test($Version=1; foo=bar;a=b); +test($Version=\1\; foo='bar'; $Path=/path; $Domain=\localhost\); test($Version=1;foo=bar;a=b; ; ); test($Version=1;foo=;a=b; ; ); test($Version=1;foo= ;a=b; ; ); @@ -505,6 +506,6 @@ } } - */ + } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http Cookies.java
larryi 2003/02/16 17:40:55 Modified:util/java/org/apache/tomcat/util/http Cookies.java Log: Fix to return values instead of the names. Revision ChangesPath 1.3 +3 -3 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http/Cookies.java Index: Cookies.java === RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http/Cookies.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Cookies.java 31 Dec 2001 18:20:05 - 1.2 +++ Cookies.java 17 Feb 2003 01:40:55 - 1.3 @@ -321,13 +321,13 @@ continue; } if( equals( $Path, bytes, startName, endName ) ) { - sc.getPath().setBytes( bytes, startName, endName-startName ); + sc.getPath().setBytes( bytes, startValue, endValue-startValue ); } if( equals( $Domain, bytes, startName, endName ) ) { - sc.getDomain().setBytes( bytes, startName, endName-startName ); + sc.getDomain().setBytes( bytes, startValue, endValue-startValue ); } if( equals( $Port, bytes, startName, endName ) ) { - // sc.getPort().setBytes( bytes, startName, endName-startName ); + // sc.getPort().setBytes( bytes, startValue, endValue-startValue ); } } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http Cookies.java
larryi 2003/02/16 17:45:24 Modified:util/java/org/apache/tomcat/util/http Tag: coyote_10 Cookies.java Log: Port fix from HEAD. Revision ChangesPath No revision No revision 1.2.2.1 +3 -3 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http/Cookies.java Index: Cookies.java === RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http/Cookies.java,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -r1.2 -r1.2.2.1 --- Cookies.java 31 Dec 2001 18:20:05 - 1.2 +++ Cookies.java 17 Feb 2003 01:45:24 - 1.2.2.1 @@ -321,13 +321,13 @@ continue; } if( equals( $Path, bytes, startName, endName ) ) { - sc.getPath().setBytes( bytes, startName, endName-startName ); +sc.getPath().setBytes( bytes, startValue, endValue-startValue ); } if( equals( $Domain, bytes, startName, endName ) ) { - sc.getDomain().setBytes( bytes, startName, endName-startName ); +sc.getDomain().setBytes( bytes, startValue, endValue-startValue ); } if( equals( $Port, bytes, startName, endName ) ) { - // sc.getPort().setBytes( bytes, startName, endName-startName ); +// sc.getPort().setBytes( bytes, startValue, endValue-startValue ); } } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http Cookies.java MimeHeaders.java Parameters.java ServerCookie.java
costin 01/12/31 10:20:05 Modified:util/java/org/apache/tomcat/util/buf Base64.java ByteChunk.java DateTool.java HexUtils.java MessageBytes.java TimeStamp.java UDecoder.java UEncoder.java util/java/org/apache/tomcat/util/collections LRUCache.java SimpleHashtable.java SimplePool.java util/java/org/apache/tomcat/util/http Cookies.java MimeHeaders.java Parameters.java ServerCookie.java Log: Synchronize utils with 3.3 release. Revision ChangesPath 1.2 +1 -5 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/Base64.java Index: Base64.java === RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/Base64.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Base64.java 16 May 2001 23:17:55 - 1.1 +++ Base64.java 31 Dec 2001 18:20:04 - 1.2 @@ -1,8 +1,4 @@ /* - * $Header: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/Base64.java,v 1.1 2001/05/16 23:17:55 seguin Exp $ - * $Revision: 1.1 $ - * $Date: 2001/05/16 23:17:55 $ - * * * * The Apache Software License, Version 1.1 @@ -74,7 +70,7 @@ * This class is used by XML Schema binary format validation * * @author Jeffrey Rodriguez - * @version $Revision: 1.1 $ $Date: 2001/05/16 23:17:55 $ + * @version $Revision: 1.2 $ $Date: 2001/12/31 18:20:04 $ */ public final class Base64 { 1.5 +1 -1 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/ByteChunk.java Index: ByteChunk.java === RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/ByteChunk.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ByteChunk.java20 Jun 2001 05:24:47 - 1.4 +++ ByteChunk.java31 Dec 2001 18:20:04 - 1.5 @@ -586,7 +586,7 @@ } return -1; } - + // Hash code // normal hash. 1.4 +41 -24 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/DateTool.java Index: DateTool.java === RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/DateTool.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- DateTool.java 9 Jun 2001 00:12:51 - 1.3 +++ DateTool.java 31 Dec 2001 18:20:04 - 1.4 @@ -84,19 +84,19 @@ /** GMT timezone - all HTTP dates are on GMT */ -private final static TimeZone GMT_ZONE = TimeZone.getTimeZone(GMT); +public final static TimeZone GMT_ZONE = TimeZone.getTimeZone(GMT); /** format for RFC 1123 date string -- Sun, 06 Nov 1994 08:49:37 GMT */ -private final static String RFC1123_PATTERN = +public final static String RFC1123_PATTERN = EEE, dd MMM HH:mm:ss z; // format for RFC 1036 date string -- Sunday, 06-Nov-94 08:49:37 GMT -private final static String rfc1036Pattern = +public final static String rfc1036Pattern = E, dd-MMM-yy HH:mm:ss z; // format for C asctime() date string -- Sun Nov 6 08:49:37 1994 -private final static String asctimePattern = +public final static String asctimePattern = EEE MMM d HH:mm:ss ; /** Pattern used for old cookies @@ -127,6 +127,9 @@ asctimeFormat.setTimeZone(GMT_ZONE); } +private static String rfc1123DS; +private static long rfc1123Sec; + private static StringManager sm = StringManager.getManager(org.apache.tomcat.util.buf.res); @@ -139,7 +142,21 @@ /** */ public static String format1123( Date d ) { - return rfc1123Format.format( d ); +long dt = d.getTime() % 1000; +if ((rfc1123DS != null) (dt == rfc1123Sec)) +return rfc1123DS; +rfc1123DS = rfc1123Format.format( d ); +rfc1123Sec = dt; +return rfc1123DS; +} + +public static String format1123( Date d,DateFormat df ) { +long dt = d.getTime() % 1000; +if ((rfc1123DS != null) (dt == rfc1123Sec)) +return rfc1123DS; +rfc1123DS = df.format( d ); +rfc1123Sec = dt; +return rfc1123DS; } @@ -149,13 +166,19 @@ public static void formatOldCookie( Date d, StringBuffer sb,