Skip to content

Commit 37bc94a

Browse files
committed
Merge branch '2.19' into 2.20
2 parents 32e5c7e + 326e673 commit 37bc94a

7 files changed

Lines changed: 37 additions & 15 deletions

File tree

cbor/src/main/java/com/fasterxml/jackson/dataformat/cbor/CBORParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2629,7 +2629,7 @@ private final int _finishLongTextAscii(int len) throws IOException
26292629
int outPtr = 0;
26302630
while (len > 0) {
26312631
// load as much input as possible
2632-
int size = Math.min(len, Math.min(outBuf.length, input.length));
2632+
int size = Math.min(len, Math.min((outBuf.length - outPtr), input.length));
26332633
if (!_tryToLoadToHaveAtLeast(size)) {
26342634
return len;
26352635
}

cbor/src/test/java/com/fasterxml/jackson/dataformat/cbor/parse/ParseLongAsciiTextTest.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,27 @@ public class ParseLongAsciiTextTest extends CBORTestBase
1717

1818
@Test
1919
public void testLongNonChunkedAsciiText() throws Exception {
20-
try (CBORParser p = CBOR_F.createParser(this.getClass().getResourceAsStream("/data/macbeth-snippet-non-chunked.cbor"))) {
21-
assertEquals(JsonToken.VALUE_STRING, p.nextToken());
22-
String expected = new String(readResource("/data/macbeth-snippet.txt"), "UTF-8");
23-
assertEquals(expected, p.getText());
20+
// run several times to allow the internal buffers
21+
// to grow
22+
for (int x = 0; x < 3 ; x++) {
23+
try (CBORParser p = CBOR_F.createParser(this.getClass().getResourceAsStream("/data/macbeth-snippet-non-chunked.cbor"))) {
24+
assertEquals(JsonToken.VALUE_STRING, p.nextToken());
25+
String expected = new String(readResource("/data/macbeth-snippet.txt"), "UTF-8");
26+
assertEquals(expected, p.getText());
27+
}
2428
}
2529
}
2630

2731
@Test
2832
public void testLongChunkedAsciiText() throws Exception {
29-
try (CBORParser p = CBOR_F.createParser(this.getClass().getResourceAsStream("/data/macbeth-snippet-chunked.cbor"))) {
30-
assertEquals(JsonToken.VALUE_STRING, p.nextToken());
31-
String expected = new String(readResource("/data/macbeth-snippet.txt"), StandardCharsets.UTF_8);
32-
assertEquals(expected, p.getText());
33+
// run several times to allow the internal buffers
34+
// to grow
35+
for (int x = 0; x < 3 ; x++) {
36+
try (CBORParser p = CBOR_F.createParser(this.getClass().getResourceAsStream("/data/macbeth-snippet-chunked.cbor"))) {
37+
assertEquals(JsonToken.VALUE_STRING, p.nextToken());
38+
String expected = new String(readResource("/data/macbeth-snippet.txt"), StandardCharsets.UTF_8);
39+
assertEquals(expected, p.getText());
40+
}
3341
}
3442
}
3543
}

cbor/src/test/resources/data/macbeth-snippet-chunked.cbor

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
y�---
1+
y�The Tragedy of Macbeth, often shortened to Macbeth, is a tragedy by William Shakespeare, estimated to have been first performed in 1606
2+
---
23
Act I, Scene
34

45
A desert place.
@@ -117,11 +118,11 @@ First Witch. Where hast thou been, sister?
117118
Second Witch. Killing swine.
118119
Third Witch. Sister, where thou?
119120
First Witch. A sailor's wife had chestnuts in her lap,
120-
And munch'd, and munch'd, and munch'd:-
121+
And munch'd, and munch'd, any�d munch'd:-
121122
'Give me,' quoth I:
122123
'Aroint thee, witch!' the rump-fed ronyon cries.
123124
Her husband's to Aleppo gone, master o' the Tiger:
124-
Buty� in a sieve I'll thither sail,
125+
But in a sieve I'll thither sail,
125126
And, like a rat without a tail,
126127
I'll do, I'll do, and I'll do.
127128
Second Witch. I'll give thee a wind.
@@ -223,12 +224,13 @@ Nothing afeard of what thyself didst make,
223224
Strange images of death. As thick as hail
224225
Came post with post; and every one did bear
225226
Thy praises in his kingdom's great defence,
226-
And pour'd them down before him.
227+
And pour'd them down before himy
228+
f.
227229
Angus. We are sent
228230
To give thee from our royal master thanks;
229231
Only to herald thee into his sight,
230232
Not pay thee.
231-
Ross. And, for an eary �nest of a greater honour,
233+
Ross. And, for an earnest of a greater honour,
232234
He bade me, from him, call thee thane of Cawdor:
233235
In which addition, hail, most worthy thane!
234236
For it is thine.

cbor/src/test/resources/data/macbeth-snippet-non-chunked.cbor

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
y)---
1+
y)�The Tragedy of Macbeth, often shortened to Macbeth, is a tragedy by William Shakespeare, estimated to have been first performed in 1606
2+
---
23
Act I, Scene
34

45
A desert place.

cbor/src/test/resources/data/macbeth-snippet.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
The Tragedy of Macbeth, often shortened to Macbeth, is a tragedy by William Shakespeare, estimated to have been first performed in 1606
12
---
23
Act I, Scene
34

release-notes/CREDITS-2.x

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,9 @@ Manuel Sugawara (@sugmanue)
386386
(2.19.0)
387387
* Contributed fix for #616: CBOR text gets truncated on decoding
388388
(2.19.3)
389+
* Conribued fix for #640: (cbor) CBOR throws ArrayIndexOutOfBoundsException
390+
with long ASCII text
391+
(2.20.2)
389392

390393
Josh Curry (@seadbrane)
391394
* Reported, contributed fix for #571: Unable to deserialize a pojo with IonStruct

release-notes/VERSION-2.x

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ Active maintainers:
4444
- Fixes wrt [core#1438] (ParserBase.close() not resetting current token)
4545
- Generate SBOMs [JSTEP-14]
4646

47+
-----
48+
49+
Not yet released
50+
51+
#640: (cbor) CBOR throws ArrayIndexOutOfBoundsException with long ASCII text
52+
(reported, fix contributed by Manuel S)
53+
4754
2.19.4 (29-Oct-2025)
4855
2.19.3 (29-Oct-2025)
4956

0 commit comments

Comments
 (0)