Skip to content
Snippets Groups Projects
Unverified Commit e02db37a authored by akwizgran's avatar akwizgran
Browse files

Check that transport ID isn't empty.

parent 9a3ad118
No related branches found
No related tags found
No related merge requests found
...@@ -35,18 +35,18 @@ class PayloadParserImpl implements PayloadParser { ...@@ -35,18 +35,18 @@ class PayloadParserImpl implements PayloadParser {
BdfReader r = bdfReaderFactory.createReader(in); BdfReader r = bdfReaderFactory.createReader(in);
r.readListStart(); // Payload start r.readListStart(); // Payload start
int proto = (int) r.readLong(); int proto = (int) r.readLong();
if (proto != PROTOCOL_VERSION) if (proto != PROTOCOL_VERSION) throw new FormatException();
throw new FormatException();
byte[] commitment = r.readRaw(COMMIT_LENGTH); byte[] commitment = r.readRaw(COMMIT_LENGTH);
if (commitment.length != COMMIT_LENGTH) if (commitment.length != COMMIT_LENGTH) throw new FormatException();
throw new FormatException(); List<TransportDescriptor> descriptors =
List<TransportDescriptor> descriptors = new ArrayList<TransportDescriptor>(); new ArrayList<TransportDescriptor>();
r.readListStart(); // Descriptors start r.readListStart(); // Descriptors start
while (r.hasList()) { while (!r.hasListEnd()) {
r.readListStart(); r.readListStart();
while (!r.hasListEnd()) { while (!r.hasListEnd()) {
TransportId id = String idString = r.readString(MAX_PROPERTY_LENGTH);
new TransportId(r.readString(MAX_PROPERTY_LENGTH)); if (idString.isEmpty()) throw new FormatException();
TransportId id = new TransportId(idString);
TransportProperties p = new TransportProperties(); TransportProperties p = new TransportProperties();
r.readDictionaryStart(); r.readDictionaryStart();
while (!r.hasDictionaryEnd()) { while (!r.hasDictionaryEnd()) {
...@@ -61,8 +61,7 @@ class PayloadParserImpl implements PayloadParser { ...@@ -61,8 +61,7 @@ class PayloadParserImpl implements PayloadParser {
} }
r.readListEnd(); // Descriptors end r.readListEnd(); // Descriptors end
r.readListEnd(); // Payload end r.readListEnd(); // Payload end
if (!r.eof()) if (!r.eof()) throw new FormatException();
throw new FormatException();
return new Payload(commitment, descriptors); return new Payload(commitment, descriptors);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment