mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Check that EOF occurs when expected.
This commit is contained in:
@@ -28,7 +28,6 @@ import net.sf.briar.api.serial.ReaderFactory;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
/** A bundle that deserialises its contents on demand using a reader. */
|
||||
class BundleReaderImpl implements BundleReader {
|
||||
|
||||
private static enum State { START, FIRST_BATCH, MORE_BATCHES, END };
|
||||
@@ -98,6 +97,8 @@ class BundleReaderImpl implements BundleReader {
|
||||
if(state != State.MORE_BATCHES) throw new IllegalStateException();
|
||||
if(r.hasListEnd()) {
|
||||
r.readListEnd();
|
||||
// That should be all
|
||||
if(!r.eof()) throw new FormatException();
|
||||
state = State.END;
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ import net.sf.briar.api.serial.Raw;
|
||||
import net.sf.briar.api.serial.Writer;
|
||||
import net.sf.briar.api.serial.WriterFactory;
|
||||
|
||||
/** A bundle builder that serialises its contents using a writer. */
|
||||
class BundleWriterImpl implements BundleWriter {
|
||||
|
||||
private static enum State { START, FIRST_BATCH, MORE_BATCHES, END };
|
||||
|
||||
@@ -60,9 +60,13 @@ class MessageParserImpl implements MessageParser {
|
||||
AuthorId author = new AuthorId(messageDigest.digest());
|
||||
// Skip the message body
|
||||
r.readRaw();
|
||||
// Verify the signature
|
||||
// Record the length of the signed data
|
||||
int messageLength = (int) r.getRawBytesRead();
|
||||
// Read the signature
|
||||
byte[] sig = r.readRaw();
|
||||
// That should be all
|
||||
if(!r.eof()) throw new FormatException();
|
||||
// Verify the signature
|
||||
PublicKey publicKey;
|
||||
try {
|
||||
publicKey = keyParser.parsePublicKey(encodedKey);
|
||||
|
||||
Reference in New Issue
Block a user