mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 19:59:05 +01:00
Don't accept empty acks, batches or offers.
This commit is contained in:
@@ -2,7 +2,6 @@ package net.sf.briar.protocol;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -35,9 +34,10 @@ class AckReader implements ObjectReader<Ack> {
|
||||
r.addConsumer(counting);
|
||||
r.readStructId(Types.ACK);
|
||||
r.setMaxBytesLength(UniqueId.LENGTH);
|
||||
Collection<Bytes> raw = r.readList(Bytes.class);
|
||||
List<Bytes> raw = r.readList(Bytes.class);
|
||||
r.resetMaxBytesLength();
|
||||
r.removeConsumer(counting);
|
||||
if(raw.isEmpty()) throw new FormatException();
|
||||
// Convert the byte arrays to batch IDs
|
||||
List<BatchId> batches = new ArrayList<BatchId>();
|
||||
for(Bytes b : raw) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.sf.briar.protocol;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import net.sf.briar.api.FormatException;
|
||||
import net.sf.briar.api.crypto.CryptoComponent;
|
||||
import net.sf.briar.api.crypto.MessageDigest;
|
||||
import net.sf.briar.api.protocol.BatchId;
|
||||
@@ -44,6 +45,7 @@ class BatchReader implements ObjectReader<UnverifiedBatch> {
|
||||
r.removeObjectReader(Types.MESSAGE);
|
||||
r.removeConsumer(digesting);
|
||||
r.removeConsumer(counting);
|
||||
if(messages.isEmpty()) throw new FormatException();
|
||||
// Build and return the batch
|
||||
BatchId id = new BatchId(messageDigest.digest());
|
||||
return batchFactory.createUnverifiedBatch(id, messages);
|
||||
|
||||
@@ -2,7 +2,6 @@ package net.sf.briar.protocol;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -35,9 +34,10 @@ class OfferReader implements ObjectReader<Offer> {
|
||||
r.addConsumer(counting);
|
||||
r.readStructId(Types.OFFER);
|
||||
r.setMaxBytesLength(UniqueId.LENGTH);
|
||||
Collection<Bytes> raw = r.readList(Bytes.class);
|
||||
List<Bytes> raw = r.readList(Bytes.class);
|
||||
r.resetMaxBytesLength();
|
||||
r.removeConsumer(counting);
|
||||
if(raw.isEmpty()) throw new FormatException();
|
||||
// Convert the byte arrays to message IDs
|
||||
List<MessageId> messages = new ArrayList<MessageId>();
|
||||
for(Bytes b : raw) {
|
||||
|
||||
Reference in New Issue
Block a user