File tree 5 files changed +38
-6
lines changed
main/java/com/fasterxml/jackson/dataformat/cbor
test/java/com/fasterxml/jackson/dataformat/cbor/fuzz
5 files changed +38
-6
lines changed Original file line number Diff line number Diff line change @@ -851,11 +851,16 @@ protected JsonToken _handleTaggedBinary(int tag) throws IOException
851
851
// First: get the data
852
852
_finishToken ();
853
853
854
- BigInteger nr = new BigInteger (_binaryValue );
855
- if (neg ) {
856
- nr = nr .negate ();
854
+ // [dataformats-binar#261]: handle this special case
855
+ if (_binaryValue .length == 0 ) {
856
+ _numberBigInt = BigInteger .ZERO ;
857
+ } else {
858
+ BigInteger nr = new BigInteger (_binaryValue );
859
+ if (neg ) {
860
+ nr = nr .negate ();
861
+ }
862
+ _numberBigInt = nr ;
857
863
}
858
- _numberBigInt = nr ;
859
864
_numTypesValid = NR_BIGINT ;
860
865
_tagValue = -1 ;
861
866
return (_currToken = JsonToken .VALUE_NUMBER_INT );
Original file line number Diff line number Diff line change 6
6
7
7
import com .fasterxml .jackson .dataformat .cbor .CBORTestBase ;
8
8
9
- public class Fuzz32173ShortTextTest extends CBORTestBase
9
+ public class Fuzz32173LongTextTest extends CBORTestBase
10
10
{
11
11
private final ObjectMapper MAPPER = cborMapper ();
12
12
@@ -23,5 +23,4 @@ public void testInvalidShortText() throws Exception
23
23
verifyException (e , "Unexpected end-of-input in VALUE_STRING" );
24
24
}
25
25
}
26
-
27
26
}
Original file line number Diff line number Diff line change
1
+ package com .fasterxml .jackson .dataformat .cbor .fuzz ;
2
+
3
+ import java .math .BigInteger ;
4
+
5
+ import com .fasterxml .jackson .databind .JsonNode ;
6
+ import com .fasterxml .jackson .databind .ObjectMapper ;
7
+ import com .fasterxml .jackson .dataformat .cbor .CBORTestBase ;
8
+
9
+ public class Fuzz32250BigIntegerTest extends CBORTestBase
10
+ {
11
+ private final ObjectMapper MAPPER = cborMapper ();
12
+
13
+ public void testInvalidShortText () throws Exception
14
+ {
15
+ final byte [] input = new byte [] {
16
+ (byte ) 0xC3 ,
17
+ 0x5F , (byte ) 0xFF
18
+ };
19
+ JsonNode root = MAPPER .readTree (input );
20
+ assertTrue (root .isNumber ());
21
+ assertTrue (root .isBigInteger ());
22
+ assertEquals (BigInteger .ZERO , root .bigIntegerValue ());
23
+ }
24
+ }
Original file line number Diff line number Diff line change @@ -172,6 +172,8 @@ Fabian Meumertzheim (fmeum@github)
172
172
* Reported #259 : (cbor) Failed to handle case of alleged String with length of
173
173
Integer .MAX_VALUE
174
174
(2.12 .3 )
175
+ * Reported #261 (cbor) CBORParser need to validate zero-length byte[] for BigInteger
176
+ (2.12 .3 )
175
177
176
178
(jhhladky @github )
177
179
Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ Modules:
18
18
(reported by Fabian M )
19
19
#259 : (cbor ) Failed to handle case of alleged String with length of Integer .MAX_VALUE
20
20
(reported by Fabian M )
21
+ #261 (cbor ) CBORParser need to validate zero - length byte [] for BigInteger
22
+ (reported by Fabian M )
21
23
22
24
2.12 .2 (03 - Mar - 2021 )
23
25
You can’t perform that action at this time.
0 commit comments