Check that author and group names aren't empty.

This commit is contained in:
akwizgran
2014-01-31 17:23:14 +00:00
parent 93890d56f6
commit cde4ca574f
9 changed files with 26 additions and 9 deletions

View File

@@ -8,6 +8,7 @@ import java.io.IOException;
import org.briarproject.api.Author;
import org.briarproject.api.AuthorId;
import org.briarproject.api.FormatException;
import org.briarproject.api.crypto.CryptoComponent;
import org.briarproject.api.crypto.MessageDigest;
import org.briarproject.api.serial.DigestingConsumer;
@@ -29,6 +30,7 @@ class AuthorReader implements StructReader<Author> {
// Read and digest the data
r.readStructStart(AUTHOR);
String name = r.readString(MAX_AUTHOR_NAME_LENGTH);
if(name.length() == 0) throw new FormatException();
byte[] publicKey = r.readBytes(MAX_PUBLIC_KEY_LENGTH);
r.readStructEnd();
// Reset the reader

View File

@@ -213,7 +213,7 @@ class PacketReaderImpl implements PacketReader {
public TransportAck readTransportAck() throws IOException {
r.readStructStart(TRANSPORT_ACK);
String idString = r.readString(MAX_TRANSPORT_ID_LENGTH);
if(idString.equals("")) throw new FormatException();
if(idString.length() == 0) throw new FormatException();
TransportId id = new TransportId(idString);
long version = r.readInteger();
if(version < 0) throw new FormatException();
@@ -233,7 +233,7 @@ class PacketReaderImpl implements PacketReader {
r.readStructStart(TRANSPORT_UPDATE);
// Read the transport ID
String idString = r.readString(MAX_TRANSPORT_ID_LENGTH);
if(idString.equals("")) throw new FormatException();
if(idString.length() == 0) throw new FormatException();
TransportId id = new TransportId(idString);
// Read the transport properties
Map<String, String> p = new HashMap<String, String>();