martin-g commented on code in PR #3625:
URL: https://github.com/apache/avro/pull/3625#discussion_r2690730758
##########
lang/java/avro/src/main/java/org/apache/avro/file/DeflateCodec.java:
##########
@@ -78,10 +93,32 @@ public ByteBuffer compress(ByteBuffer data) throws
IOException {
@Override
public ByteBuffer decompress(ByteBuffer data) throws IOException {
+ long maxLength = getMaxDecompressLength();
NonCopyingByteArrayOutputStream baos = new
NonCopyingByteArrayOutputStream(DEFAULT_BUFFER_SIZE);
- try (OutputStream outputStream = new InflaterOutputStream(baos,
getInflater())) {
- outputStream.write(data.array(), computeOffset(data), data.remaining());
+ byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
+ long totalBytes = 0;
+
+ Inflater inflater = getInflater();
+ inflater.setInput(data.array(), computeOffset(data), data.remaining());
+
+ try {
+ while (!inflater.finished()) {
+ int len = inflater.inflate(buffer);
+ if (len == 0 && inflater.needsInput()) {
+ break;
+ }
+ totalBytes += len;
+ if (totalBytes > maxLength) {
+ throw new AvroRuntimeException(
Review Comment:
```suggestion
throw new IOException(
```
The method declares that it throws IOException when there are problems.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]