chunk.setBytes(buf, pos, remaining);
pos = pos + remaining;
remaining = 0;
- needCRLFParse = true;
+ //we need a CRLF
+ if ((pos+1) >= lastValid) {
+ //if we call parseCRLF we overrun the buffer here
+ //so we defer it to the next call BZ 11117
+ needCRLFParse = true;
+ } else {
+ parseCRLF(); //parse the CRLF immediately
+ }
}
return result;
throws IOException {
boolean eol = false;
+ boolean crfound = false;
while (!eol) {
}
if (buf[pos] == Constants.CR) {
+ if (crfound) throw new IOException("Invalid CRLF, two CR characters encountered.");
+ crfound = true;
} else if (buf[pos] == Constants.LF) {
+ if (!crfound) throw new IOException("Invalid CRLF, no CR character encountered.");
eol = true;
} else {
throw new IOException("Invalid CRLF");