Skip to content

Commit e583711

Browse files
committed
debezium/dbz#1503 Detect extra large events
Signed-off-by: Jiri Pechanec <jiri.pechanec@centrum.cz>
1 parent fd3c68c commit e583711

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

debezium-connector-binlog/src/main/java/io/debezium/connector/binlog/event/TransactionPayloadDeserializer.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.github.shyiko.mysql.binlog.event.deserialization.TransactionPayloadEventDataDeserializer;
2020
import com.github.shyiko.mysql.binlog.io.ByteArrayInputStream;
2121

22+
import io.debezium.DebeziumException;
2223
import io.debezium.config.CommonConnectorConfig;
2324

2425
/**
@@ -82,7 +83,11 @@ public TransactionPayloadEventData deserialize(ByteArrayInputStream inputStream)
8283

8384
// Decompress the payload
8485
byte[] src = eventData.getPayload();
85-
byte[] dst = ByteBuffer.allocate(eventData.getUncompressedSize()).array();
86+
final var uncompressedSize = eventData.getUncompressedSize();
87+
if (uncompressedSize > Integer.MAX_VALUE) {
88+
throw new DebeziumException("Cannot process event of size '" + uncompressedSize + "' larger than max array size");
89+
}
90+
final var dst = ByteBuffer.allocate((int) uncompressedSize).array();
8691
Zstd.decompressByteArray(dst, 0, dst.length, src, 0, src.length);
8792

8893
// Read and store events from decompressed byte array into input stream

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@
139139
<!-- Database drivers, should align with databases -->
140140
<version.postgresql.driver>42.7.7</version.postgresql.driver>
141141
<version.mysql.driver>9.1.0</version.mysql.driver>
142-
<version.mysql.binlog>0.40.3</version.mysql.binlog>
142+
<version.mysql.binlog>0.40.4</version.mysql.binlog>
143143
<version.mongo.driver>5.5.1</version.mongo.driver>
144144
<version.sqlserver.driver>12.4.2.jre8</version.sqlserver.driver>
145145
<version.db2.driver>11.5.0.0</version.db2.driver>

0 commit comments

Comments
 (0)