File tree Expand file tree Collapse file tree 3 files changed +11
-5
lines changed
cbor/src/main/java/com/fasterxml/jackson/dataformat/cbor Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -701,8 +701,7 @@ public JsonToken nextToken() throws IOException
701701 _numberLong = -l - 1L ;
702702 _numTypesValid = NR_LONG ;
703703 } else {
704- BigInteger unsignedBase = _bigPositive (l );
705- _numberBigInt = unsignedBase .negate ().subtract (BigInteger .ONE );
704+ _numberBigInt = _bigNegative (l );
706705 _numTypesValid = NR_BIGINT ;
707706 }
708707 }
@@ -1176,8 +1175,7 @@ public String nextTextValue() throws IOException
11761175 _numberLong = l ;
11771176 _numTypesValid = NR_LONG ;
11781177 } else {
1179- BigInteger unsignedBase = _bigPositive (l );
1180- _numberBigInt = unsignedBase .negate ().subtract (BigInteger .ONE );
1178+ _numberBigInt = _bigNegative (l );
11811179 _numTypesValid = NR_BIGINT ;
11821180 }
11831181 }
@@ -3145,6 +3143,8 @@ private final BigInteger _bigPositive(long l) {
31453143 }
31463144
31473145 private final BigInteger _bigNegative (long l ) {
3148- return BigInteger .valueOf (l ).subtract (BigInteger .ONE );
3146+ // 03-Dec-2017, tatu: [dataformats-binary#149] Careful with overflow
3147+ BigInteger unsignedBase = _bigPositive (l );
3148+ return unsignedBase .negate ().subtract (BigInteger .ONE );
31493149 }
31503150}
Original file line number Diff line number Diff line change @@ -56,3 +56,7 @@ philipa@github
5656* Reported #114 (cbor), contributed fix for: copyStructure(): avoid duplicate tags
5757 when copying tagged binary
5858 (2.9.3)
59+
60+ Jacek Lach (JacekLach@github)
61+ * Reported #124: Invalid value returned for negative int32 where the absolute value is > 2^31 - 1
62+ (2.9.3)
Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ Modules:
1515 (contributed by philipa@github)
1616#116: (protobuf) Should skip the positive byte which is the last byte of an varint
1717 (contributed by marsqing@github)
18+ #124: Invalid value returned for negative int32 where the absolute value is > 2^31 - 1
19+ (repoted by Jacek L)
1820- (protobuf) Minor fix to skipping with `nextFieldName()`
1921- (avro) Fix a typo in SPI Metadata (META-INF/services/com.fasterxml.jackson.core.JsonFactory)
2022
You can’t perform that action at this time.
0 commit comments