@@ -212,6 +212,11 @@ private boolean readOneWithoutStackLarge(Accept a, final int b) throws IOExcepti
212212 headByte = REQUIRE_TO_READ_HEAD ;
213213 return true ;
214214 }
215+ if (count >= rawSizeLimit ) {
216+ String reason = String .format ("Size of raw (%d) over limit at %d" ,
217+ new Object [] { count , rawSizeLimit });
218+ throw new SizeLimitException (reason );
219+ }
215220 in .advance ();
216221 if (!tryReferRawBody (a , count )) {
217222 readRawBody (count );
@@ -224,17 +229,17 @@ private boolean readOneWithoutStackLarge(Accept a, final int b) throws IOExcepti
224229 case 0xdb : // raw 32
225230 {
226231 int count = in .getInt ();
227- if (count < 0 || count > rawSizeLimit ) {
228- String reason = String .format ("Size of raw (%d) over limit at %d" ,
229- new Object [] { count , rawSizeLimit });
230- throw new SizeLimitException (reason );
231- }
232232 if (count == 0 ) {
233233 a .acceptEmptyRaw ();
234234 in .advance ();
235235 headByte = REQUIRE_TO_READ_HEAD ;
236236 return true ;
237237 }
238+ if (count < 0 || count >= rawSizeLimit ) {
239+ String reason = String .format ("Size of raw (%d) over limit at %d" ,
240+ new Object [] { count , rawSizeLimit });
241+ throw new SizeLimitException (reason );
242+ }
238243 in .advance ();
239244 if (!tryReferRawBody (a , count )) {
240245 readRawBody (count );
@@ -247,7 +252,7 @@ private boolean readOneWithoutStackLarge(Accept a, final int b) throws IOExcepti
247252 case 0xdc : // array 16
248253 {
249254 int count = in .getShort () & 0xffff ;
250- if (count > arraySizeLimit ) {
255+ if (count >= arraySizeLimit ) {
251256 String reason = String .format ("Size of array (%d) over limit at %d" ,
252257 new Object [] { count , arraySizeLimit });
253258 throw new SizeLimitException (reason );
@@ -262,7 +267,7 @@ private boolean readOneWithoutStackLarge(Accept a, final int b) throws IOExcepti
262267 case 0xdd : // array 32
263268 {
264269 int count = in .getInt ();
265- if (count < 0 || count > arraySizeLimit ) {
270+ if (count < 0 || count >= arraySizeLimit ) {
266271 String reason = String .format ("Size of array (%d) over limit at %d" ,
267272 new Object [] { count , arraySizeLimit });
268273 throw new SizeLimitException (reason );
@@ -277,7 +282,7 @@ private boolean readOneWithoutStackLarge(Accept a, final int b) throws IOExcepti
277282 case 0xde : // map 16
278283 {
279284 int count = in .getShort () & 0xffff ;
280- if (count > mapSizeLimit ) {
285+ if (count >= mapSizeLimit ) {
281286 String reason = String .format ("Size of map (%d) over limit at %d" ,
282287 new Object [] { count , mapSizeLimit });
283288 throw new SizeLimitException (reason );
@@ -292,7 +297,7 @@ private boolean readOneWithoutStackLarge(Accept a, final int b) throws IOExcepti
292297 case 0xdf : // map 32
293298 {
294299 int count = in .getInt ();
295- if (count < 0 || count > mapSizeLimit ) {
300+ if (count < 0 || count >= mapSizeLimit ) {
296301 String reason = String .format ("Size of map (%d) over limit at %d" ,
297302 new Object [] { count , mapSizeLimit });
298303 throw new SizeLimitException (reason );
0 commit comments