@@ -224,8 +224,10 @@ private boolean readOneWithoutStackLarge(Accept a, final int b) throws IOExcepti
224224 case 0xdb : // raw 32
225225 {
226226 int count = in .getInt ();
227- if (count < 0 ) {
228- throw new IOException ("Raw size too large" ); // TODO error MessageSizeException
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 );
229231 }
230232 if (count == 0 ) {
231233 a .acceptEmptyRaw ();
@@ -255,8 +257,10 @@ private boolean readOneWithoutStackLarge(Accept a, final int b) throws IOExcepti
255257 case 0xdd : // array 32
256258 {
257259 int count = in .getInt ();
258- if (count < 0 ) {
259- throw new IOException ("Array size too large" ); // TODO error MessageSizeException
260+ if (count < 0 || count > arraySizeLimit ) {
261+ String reason = String .format ("Size of array (%d) over limit at %d" ,
262+ new Object [] { count , arraySizeLimit });
263+ throw new SizeLimitException (reason );
260264 }
261265 a .acceptArray (count );
262266 stack .reduceCount ();
@@ -278,8 +282,10 @@ private boolean readOneWithoutStackLarge(Accept a, final int b) throws IOExcepti
278282 case 0xdf : // map 32
279283 {
280284 int count = in .getInt ();
281- if (count < 0 ) {
282- throw new IOException ("Map size too large" ); // TODO error MessageSizeException
285+ if (count < 0 && count > mapSizeLimit ) {
286+ String reason = String .format ("Size of map (%d) over limit at %d" ,
287+ new Object [] { count , mapSizeLimit });
288+ throw new SizeLimitException (reason );
283289 }
284290 a .acceptMap (count );
285291 stack .reduceCount ();
0 commit comments