pjfanning commented on code in PR #1071:
URL: https://github.com/apache/poi/pull/1071#discussion_r3250405568


##########
poi-scratchpad/src/main/java/org/apache/poi/hmef/CompressedRTF.java:
##########
@@ -127,4 +162,48 @@ protected int populateDictionary(byte[] dict) {
      // Start adding new codes after the constants
      return preload.length;
    }
+
+   private void copyCompressedPayload(InputStream src, OutputStream res) 
throws IOException {
+      long remaining = getCompressedSize();
+      byte[] buffer = IOUtils.safelyAllocate(Math.min(8192L, remaining), 
MAX_RECORD_LENGTH);
+      while (remaining > 0) {
+         int read = src.read(buffer, 0, (int)Math.min(buffer.length, 
remaining));
+         if (read < 0) {
+            throw new IOException("Not enough data to read " + 
getCompressedSize() + " bytes of uncompressed RTF");
+         }
+         res.write(buffer, 0, read);
+         remaining -= read;
+      }
+   }
+
+   private static final class LimitedOutputStream extends OutputStream {

Review Comment:
   
https://github.com/apache/commons-io/blob/master/src/main/java/org/apache/commons/io/output/CountingOutputStream.java
 should be usable - don't really like declaring our own class for this



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to