mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-12-07 21:01:16 +01:00
OpenPgpMessageInputStream: Return -1 instead of throwing MalformedOpenPgpMessageException when calling read() on drained stream
This commit is contained in:
parent
558036c485
commit
52fa7e4d46
3 changed files with 23 additions and 0 deletions
|
|
@ -744,6 +744,7 @@ public class OpenPgpMessageInputStream extends DecryptionStream {
|
|||
throws IOException {
|
||||
if (nestedInputStream == null) {
|
||||
if (packetInputStream != null) {
|
||||
syntaxVerifier.next(InputSymbol.EndOfSequence);
|
||||
syntaxVerifier.assertValid();
|
||||
}
|
||||
return -1;
|
||||
|
|
@ -774,6 +775,7 @@ public class OpenPgpMessageInputStream extends DecryptionStream {
|
|||
super.close();
|
||||
if (closed) {
|
||||
if (packetInputStream != null) {
|
||||
syntaxVerifier.next(InputSymbol.EndOfSequence);
|
||||
syntaxVerifier.assertValid();
|
||||
}
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -132,6 +132,10 @@ public class OpenPgpMessageSyntax implements Syntax {
|
|||
@Nonnull
|
||||
Transition fromValid(@Nonnull InputSymbol input, @Nullable StackSymbol stackItem)
|
||||
throws MalformedOpenPgpMessageException {
|
||||
if (input == InputSymbol.EndOfSequence) {
|
||||
// allow subsequent read() calls.
|
||||
return new Transition(State.Valid);
|
||||
}
|
||||
// There is no applicable transition rule out of Valid
|
||||
throw new MalformedOpenPgpMessageException(State.Valid, input, stackItem);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue