mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
Check that author and group names aren't empty.
This commit is contained in:
@@ -249,7 +249,7 @@ abstract class Connector extends Thread {
|
||||
r.readListStart();
|
||||
while(!r.hasListEnd()) {
|
||||
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);
|
||||
Map<String, String> p = new HashMap<String, String>();
|
||||
r.readMapStart();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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>();
|
||||
|
||||
@@ -8,7 +8,7 @@ public class StringUtils {
|
||||
};
|
||||
|
||||
public static boolean isNullOrEmpty(String s) {
|
||||
return s == null || s.equals("");
|
||||
return s == null || s.length() == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -17,7 +17,7 @@ public class StringUtils {
|
||||
*/
|
||||
public static String head(String s, int length) {
|
||||
if(s.length() > length) return s.substring(0, length) + "...";
|
||||
else return s;
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -26,7 +26,7 @@ public class StringUtils {
|
||||
*/
|
||||
public static String tail(String s, int length) {
|
||||
if(s.length() > length) return "..." + s.substring(s.length() - length);
|
||||
else return s;
|
||||
return s;
|
||||
}
|
||||
|
||||
/** Converts the given byte array to a hex character array. */
|
||||
|
||||
Reference in New Issue
Block a user