mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-01-09 19:57:57 +01:00
Add comments to unexhaustive parsing method
This commit is contained in:
parent
69f84f24b6
commit
826331917f
1 changed files with 4 additions and 0 deletions
|
@ -111,6 +111,7 @@ public class OpenPgpInputStream extends BufferedInputStream {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void nonExhaustiveParseAndCheckPlausibility(ByteArrayInputStream bufferIn) throws IOException {
|
private void nonExhaustiveParseAndCheckPlausibility(ByteArrayInputStream bufferIn) throws IOException {
|
||||||
|
// Read the packet header
|
||||||
int hdr = bufferIn.read();
|
int hdr = bufferIn.read();
|
||||||
if (hdr < 0 || (hdr & 0x80) == 0) {
|
if (hdr < 0 || (hdr & 0x80) == 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -121,6 +122,7 @@ public class OpenPgpInputStream extends BufferedInputStream {
|
||||||
int bodyLen = 0;
|
int bodyLen = 0;
|
||||||
boolean partial = false;
|
boolean partial = false;
|
||||||
|
|
||||||
|
// Determine the packet length
|
||||||
if (newPacket) {
|
if (newPacket) {
|
||||||
tag = hdr & 0x3f;
|
tag = hdr & 0x3f;
|
||||||
|
|
||||||
|
@ -157,10 +159,12 @@ public class OpenPgpInputStream extends BufferedInputStream {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Negative body length -> garbage
|
||||||
if (bodyLen < 0) {
|
if (bodyLen < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try to unexhaustively parse the first packet bit by bit and check for plausibility
|
||||||
BCPGInputStream bcpgIn = new BCPGInputStream(bufferIn);
|
BCPGInputStream bcpgIn = new BCPGInputStream(bufferIn);
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case RESERVED:
|
case RESERVED:
|
||||||
|
|
Loading…
Reference in a new issue