3030import org .msgpack .type .ValueType ;
3131
3232public class MessagePackUnpacker extends AbstractUnpacker {
33- private static final byte REQUIRE_TO_READ_HEAD = (byte ) 0xc6 ;
33+ private static final byte REQUIRE_TO_READ_HEAD = (byte ) 0xc1 ;
3434
3535 protected final Input in ;
3636 private final UnpackerStack stack = new UnpackerStack ();
@@ -154,6 +154,9 @@ private boolean readOneWithoutStackLarge(Accept a, final int b)
154154 a .acceptBoolean (true );
155155 headByte = REQUIRE_TO_READ_HEAD ;
156156 return true ;
157+ //case 0xc4: // bin 8 -> see 0xd9
158+ //case 0xc5: // bin 16 -> see 0xda
159+ //case 0xc6: // bin 32 -> see 0xdb
157160 case 0xca : // float
158161 a .acceptFloat (in .getFloat ());
159162 in .advance ();
@@ -204,6 +207,32 @@ private boolean readOneWithoutStackLarge(Accept a, final int b)
204207 in .advance ();
205208 headByte = REQUIRE_TO_READ_HEAD ;
206209 return true ;
210+ case 0xc4 : // bin 8
211+ case 0xd9 : // str 8
212+ {
213+ int count = in .getByte ();
214+ if (count == 0 ) {
215+ a .acceptEmptyRaw ();
216+ in .advance ();
217+ headByte = REQUIRE_TO_READ_HEAD ;
218+ return true ;
219+ }
220+ if (count >= rawSizeLimit ) {
221+ String reason = String .format (
222+ "Size of raw (%d) over limit at %d" ,
223+ new Object [] { count , rawSizeLimit });
224+ throw new SizeLimitException (reason );
225+ }
226+ in .advance ();
227+ if (!tryReferRawBody (a , count )) {
228+ readRawBody (count );
229+ a .acceptRaw (raw );
230+ raw = null ;
231+ }
232+ headByte = REQUIRE_TO_READ_HEAD ;
233+ return true ;
234+ }
235+ case 0xc5 : // bin 16
207236 case 0xda : // raw 16
208237 {
209238 int count = in .getShort () & 0xffff ;
@@ -228,6 +257,7 @@ private boolean readOneWithoutStackLarge(Accept a, final int b)
228257 headByte = REQUIRE_TO_READ_HEAD ;
229258 return true ;
230259 }
260+ case 0xc6 : // bin 32
231261 case 0xdb : // raw 32
232262 {
233263 int count = in .getInt ();
@@ -614,6 +644,12 @@ public ValueType getNextType() throws IOException {
614644 case 0xd2 : // signed int 32
615645 case 0xd3 : // signed int 64
616646 return ValueType .INTEGER ;
647+ // The definition based on a minor upgrade guide.
648+ // https://github.com/msgpack/msgpack/blob/master/spec.md#impl-upgrade
649+ case 0xc4 : // bin 8
650+ case 0xc5 : // bin 16
651+ case 0xc6 : // bin 32
652+ case 0xd9 : // str8
617653 case 0xda : // raw 16
618654 case 0xdb : // raw 32
619655 return ValueType .RAW ;
0 commit comments