Author: dehort
Date: 2011-08-11 15:30:51 -0400 (Thu, 11 Aug 2011)
New Revision: 1807
Modified:
branches/JBOSSWEB_2_1_7_GA_JBPAPP-6921/java/org/apache/tomcat/util/buf/B2CConverter.java
branches/JBOSSWEB_2_1_7_GA_JBPAPP-6921/java/org/apache/tomcat/util/buf/C2BConverter.java
Log:
Backporting fix for unsafe use of position().
Originally fixed here: branches/2.1.x@1413
[JBPAPP-6921]
Modified:
branches/JBOSSWEB_2_1_7_GA_JBPAPP-6921/java/org/apache/tomcat/util/buf/B2CConverter.java
===================================================================
---
branches/JBOSSWEB_2_1_7_GA_JBPAPP-6921/java/org/apache/tomcat/util/buf/B2CConverter.java 2011-08-10
09:49:32 UTC (rev 1806)
+++
branches/JBOSSWEB_2_1_7_GA_JBPAPP-6921/java/org/apache/tomcat/util/buf/B2CConverter.java 2011-08-11
19:30:51 UTC (rev 1807)
@@ -81,8 +81,8 @@
bb = ByteBuffer.wrap(bc.getBuffer(), bc.getStart(), bc.getLength());
} else {
// Initialize the byte buffer
+ bb.limit(bc.getEnd());
bb.position(bc.getStart());
- bb.limit(bc.getEnd());
}
if ((cb == null) || (cb.array() != cc.getBuffer())) {
// Create a new char buffer if anything changed
@@ -90,8 +90,8 @@
cc.getBuffer().length - cc.getEnd());
} else {
// Initialize the char buffer
+ cb.limit(cc.getBuffer().length);
cb.position(cc.getEnd());
- cb.limit(cc.getBuffer().length);
}
CoderResult result = null;
// Parse leftover if any are present
@@ -126,8 +126,8 @@
cc.setEnd(cb.position());
// Put leftovers in the leftovers byte buffer
if (bc.getLength() > 0) {
+ leftovers.limit(leftovers.array().length);
leftovers.position(bc.getLength());
- leftovers.limit(leftovers.array().length);
bc.substract(leftovers.array(), 0, bc.getLength());
}
}
Modified:
branches/JBOSSWEB_2_1_7_GA_JBPAPP-6921/java/org/apache/tomcat/util/buf/C2BConverter.java
===================================================================
---
branches/JBOSSWEB_2_1_7_GA_JBPAPP-6921/java/org/apache/tomcat/util/buf/C2BConverter.java 2011-08-10
09:49:32 UTC (rev 1806)
+++
branches/JBOSSWEB_2_1_7_GA_JBPAPP-6921/java/org/apache/tomcat/util/buf/C2BConverter.java 2011-08-11
19:30:51 UTC (rev 1807)
@@ -75,8 +75,8 @@
bc.getBuffer().length - bc.getEnd());
} else {
// Initialize the byte buffer
+ bb.limit(bc.getBuffer().length);
bb.position(bc.getEnd());
- bb.limit(bc.getBuffer().length);
}
if ((cb == null) || (cb.array() != cc.getBuffer())) {
// Create a new char buffer if anything changed
@@ -84,8 +84,8 @@
cc.getLength());
} else {
// Initialize the char buffer
+ cb.limit(cc.getEnd());
cb.position(cc.getStart());
- cb.limit(cc.getEnd());
}
// Do the decoding and get the results into the byte chunk and the char chunk
CoderResult result = encoder.encode(cb, bb, false);
Show replies by date