mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-22 20:32:05 +01:00
Use NullOutputStream in verifier to safe resources
This commit is contained in:
parent
930448b02b
commit
fe03197f3e
1 changed files with 15 additions and 3 deletions
|
@ -10,14 +10,18 @@ import org.pgpainless.decryption_verification.OpenPgpMetadata;
|
|||
import org.pgpainless.key.OpenPgpV4Fingerprint;
|
||||
import picocli.CommandLine;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
|
||||
@CommandLine.Command(name = "verify", description = "Verify a detached signature.\nThe signed data is being read from standard input.")
|
||||
public class Verify implements Runnable {
|
||||
|
@ -66,7 +70,7 @@ public class Verify implements Runnable {
|
|||
.ignoreMissingPublicKeys()
|
||||
.build();
|
||||
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
OutputStream out = new NullOutputStream();
|
||||
Streams.pipeAll(verifier, out);
|
||||
verifier.close();
|
||||
|
||||
|
@ -141,4 +145,12 @@ public class Verify implements Runnable {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class NullOutputStream extends OutputStream {
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
// Nope
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue