Package no.difi.asic.zipbomb
Class MaxSizeProtectedOutputStream
java.lang.Object
java.io.OutputStream
java.io.ByteArrayOutputStream
no.difi.asic.zipbomb.MaxSizeProtectedOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
Use this as a simplified replacement for ByteArrayOutputStream.
It will abort writing to the output stream by throwing RuntimeException when configured size has been exceeded.
-
Field Summary
Fields inherited from class java.io.ByteArrayOutputStream
buf, count -
Constructor Summary
ConstructorsConstructorDescriptionDefault limit is set to 1 MiBMaxSizeProtectedOutputStream(long maxSize) Set any limit you want as long as it's more than 1024 bytes -
Method Summary
Methods inherited from class java.io.ByteArrayOutputStream
close, reset, size, toByteArray, toString, toString, toString, toString, writeBytes, writeToMethods inherited from class java.io.OutputStream
flush, nullOutputStream, write
-
Constructor Details
-
MaxSizeProtectedOutputStream
public MaxSizeProtectedOutputStream()Default limit is set to 1 MiB -
MaxSizeProtectedOutputStream
public MaxSizeProtectedOutputStream(long maxSize) Set any limit you want as long as it's more than 1024 bytes
-
-
Method Details
-
write
public void write(int b) - Overrides:
writein classByteArrayOutputStream
-
write
public void write(byte[] b, int off, int len) - Overrides:
writein classByteArrayOutputStream
-