mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 13:49:53 +01:00
Merge branch '441-group-descriptor-can-be-too-long-causes-crash' into 'master'
Remove MAX_GROUP_DESCRIPTOR_LENGTH Closes #441 See merge request !224
This commit is contained in:
@@ -31,7 +31,6 @@ import java.util.Collection;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import static org.briarproject.api.sync.SyncConstants.MAX_GROUP_DESCRIPTOR_LENGTH;
|
|
||||||
import static org.briarproject.api.transport.TransportConstants.TAG_LENGTH;
|
import static org.briarproject.api.transport.TransportConstants.TAG_LENGTH;
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
@@ -76,7 +75,7 @@ public class SyncIntegrationTest extends BriarTestCase {
|
|||||||
streamNumber = 123;
|
streamNumber = 123;
|
||||||
// Create a group
|
// Create a group
|
||||||
ClientId clientId = new ClientId(TestUtils.getRandomId());
|
ClientId clientId = new ClientId(TestUtils.getRandomId());
|
||||||
byte[] descriptor = new byte[MAX_GROUP_DESCRIPTOR_LENGTH];
|
byte[] descriptor = new byte[0];
|
||||||
Group group = groupFactory.createGroup(clientId, descriptor);
|
Group group = groupFactory.createGroup(clientId, descriptor);
|
||||||
// Add two messages to the group
|
// Add two messages to the group
|
||||||
long timestamp = System.currentTimeMillis();
|
long timestamp = System.currentTimeMillis();
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package org.briarproject.api.sync;
|
package org.briarproject.api.sync;
|
||||||
|
|
||||||
import static org.briarproject.api.sync.SyncConstants.MAX_GROUP_DESCRIPTOR_LENGTH;
|
|
||||||
|
|
||||||
public class Group {
|
public class Group {
|
||||||
|
|
||||||
private final GroupId id;
|
private final GroupId id;
|
||||||
@@ -9,8 +7,6 @@ public class Group {
|
|||||||
private final byte[] descriptor;
|
private final byte[] descriptor;
|
||||||
|
|
||||||
public Group(GroupId id, ClientId clientId, byte[] descriptor) {
|
public Group(GroupId id, ClientId clientId, byte[] descriptor) {
|
||||||
if (descriptor.length > MAX_GROUP_DESCRIPTOR_LENGTH)
|
|
||||||
throw new IllegalArgumentException();
|
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.clientId = clientId;
|
this.clientId = clientId;
|
||||||
this.descriptor = descriptor;
|
this.descriptor = descriptor;
|
||||||
|
|||||||
@@ -13,9 +13,6 @@ public interface SyncConstants {
|
|||||||
/** The maximum length of the packet payload in bytes. */
|
/** The maximum length of the packet payload in bytes. */
|
||||||
int MAX_PACKET_PAYLOAD_LENGTH = 32 * 1024; // 32 KiB
|
int MAX_PACKET_PAYLOAD_LENGTH = 32 * 1024; // 32 KiB
|
||||||
|
|
||||||
/** The maximum length of a group descriptor in bytes. */
|
|
||||||
int MAX_GROUP_DESCRIPTOR_LENGTH = 100; // TODO: Remove
|
|
||||||
|
|
||||||
/** The maximum length of a message in bytes. */
|
/** The maximum length of a message in bytes. */
|
||||||
int MAX_MESSAGE_LENGTH = MAX_PACKET_PAYLOAD_LENGTH - PACKET_HEADER_LENGTH;
|
int MAX_MESSAGE_LENGTH = MAX_PACKET_PAYLOAD_LENGTH - PACKET_HEADER_LENGTH;
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||||||
|
|
||||||
import static org.briarproject.api.clients.MessageQueueManager.QUEUE_STATE_KEY;
|
import static org.briarproject.api.clients.MessageQueueManager.QUEUE_STATE_KEY;
|
||||||
import static org.briarproject.api.clients.QueueMessage.QUEUE_MESSAGE_HEADER_LENGTH;
|
import static org.briarproject.api.clients.QueueMessage.QUEUE_MESSAGE_HEADER_LENGTH;
|
||||||
import static org.briarproject.api.sync.SyncConstants.MAX_GROUP_DESCRIPTOR_LENGTH;
|
|
||||||
import static org.briarproject.api.sync.SyncConstants.MESSAGE_HEADER_LENGTH;
|
import static org.briarproject.api.sync.SyncConstants.MESSAGE_HEADER_LENGTH;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
@@ -44,7 +43,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
|
|||||||
|
|
||||||
private final GroupId groupId = new GroupId(TestUtils.getRandomId());
|
private final GroupId groupId = new GroupId(TestUtils.getRandomId());
|
||||||
private final ClientId clientId = new ClientId(TestUtils.getRandomId());
|
private final ClientId clientId = new ClientId(TestUtils.getRandomId());
|
||||||
private final byte[] descriptor = new byte[MAX_GROUP_DESCRIPTOR_LENGTH];
|
private final byte[] descriptor = new byte[0];
|
||||||
private final Group group = new Group(groupId, clientId, descriptor);
|
private final Group group = new Group(groupId, clientId, descriptor);
|
||||||
private final long timestamp = System.currentTimeMillis();
|
private final long timestamp = System.currentTimeMillis();
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ import java.util.Collections;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.briarproject.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
|
import static org.briarproject.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
|
||||||
import static org.briarproject.api.sync.SyncConstants.MAX_GROUP_DESCRIPTOR_LENGTH;
|
|
||||||
import static org.briarproject.api.sync.ValidationManager.State.DELIVERED;
|
import static org.briarproject.api.sync.ValidationManager.State.DELIVERED;
|
||||||
import static org.briarproject.api.sync.ValidationManager.State.UNKNOWN;
|
import static org.briarproject.api.sync.ValidationManager.State.UNKNOWN;
|
||||||
import static org.briarproject.api.sync.ValidationManager.State.VALID;
|
import static org.briarproject.api.sync.ValidationManager.State.VALID;
|
||||||
@@ -94,7 +93,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
|||||||
public DatabaseComponentImplTest() {
|
public DatabaseComponentImplTest() {
|
||||||
clientId = new ClientId(TestUtils.getRandomId());
|
clientId = new ClientId(TestUtils.getRandomId());
|
||||||
groupId = new GroupId(TestUtils.getRandomId());
|
groupId = new GroupId(TestUtils.getRandomId());
|
||||||
byte[] descriptor = new byte[MAX_GROUP_DESCRIPTOR_LENGTH];
|
byte[] descriptor = new byte[0];
|
||||||
group = new Group(groupId, clientId, descriptor);
|
group = new Group(groupId, clientId, descriptor);
|
||||||
authorId = new AuthorId(TestUtils.getRandomId());
|
authorId = new AuthorId(TestUtils.getRandomId());
|
||||||
author = new Author(authorId, "Alice", new byte[MAX_PUBLIC_KEY_LENGTH]);
|
author = new Author(authorId, "Alice", new byte[MAX_PUBLIC_KEY_LENGTH]);
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||||
import static org.briarproject.api.db.Metadata.REMOVE;
|
import static org.briarproject.api.db.Metadata.REMOVE;
|
||||||
import static org.briarproject.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
|
import static org.briarproject.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
|
||||||
import static org.briarproject.api.sync.SyncConstants.MAX_GROUP_DESCRIPTOR_LENGTH;
|
|
||||||
import static org.briarproject.api.sync.SyncConstants.MAX_MESSAGE_LENGTH;
|
import static org.briarproject.api.sync.SyncConstants.MAX_MESSAGE_LENGTH;
|
||||||
import static org.briarproject.api.sync.ValidationManager.State.DELIVERED;
|
import static org.briarproject.api.sync.ValidationManager.State.DELIVERED;
|
||||||
import static org.briarproject.api.sync.ValidationManager.State.INVALID;
|
import static org.briarproject.api.sync.ValidationManager.State.INVALID;
|
||||||
@@ -83,7 +82,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
|||||||
public H2DatabaseTest() throws Exception {
|
public H2DatabaseTest() throws Exception {
|
||||||
groupId = new GroupId(TestUtils.getRandomId());
|
groupId = new GroupId(TestUtils.getRandomId());
|
||||||
ClientId clientId = new ClientId(TestUtils.getRandomId());
|
ClientId clientId = new ClientId(TestUtils.getRandomId());
|
||||||
byte[] descriptor = new byte[MAX_GROUP_DESCRIPTOR_LENGTH];
|
byte[] descriptor = new byte[0];
|
||||||
group = new Group(groupId, clientId, descriptor);
|
group = new Group(groupId, clientId, descriptor);
|
||||||
AuthorId authorId = new AuthorId(TestUtils.getRandomId());
|
AuthorId authorId = new AuthorId(TestUtils.getRandomId());
|
||||||
author = new Author(authorId, "Alice", new byte[MAX_PUBLIC_KEY_LENGTH]);
|
author = new Author(authorId, "Alice", new byte[MAX_PUBLIC_KEY_LENGTH]);
|
||||||
@@ -619,7 +618,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
|||||||
for (int i = 0; i < 100; i++) {
|
for (int i = 0; i < 100; i++) {
|
||||||
GroupId id = new GroupId(TestUtils.getRandomId());
|
GroupId id = new GroupId(TestUtils.getRandomId());
|
||||||
ClientId clientId = new ClientId(TestUtils.getRandomId());
|
ClientId clientId = new ClientId(TestUtils.getRandomId());
|
||||||
byte[] descriptor = new byte[MAX_GROUP_DESCRIPTOR_LENGTH];
|
byte[] descriptor = new byte[0];
|
||||||
groups.add(new Group(id, clientId, descriptor));
|
groups.add(new Group(id, clientId, descriptor));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1274,7 +1273,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
|||||||
// Add a second group
|
// Add a second group
|
||||||
GroupId groupId1 = new GroupId(TestUtils.getRandomId());
|
GroupId groupId1 = new GroupId(TestUtils.getRandomId());
|
||||||
Group group1 = new Group(groupId1, group.getClientId(),
|
Group group1 = new Group(groupId1, group.getClientId(),
|
||||||
TestUtils.getRandomBytes(MAX_GROUP_DESCRIPTOR_LENGTH));
|
TestUtils.getRandomBytes(42));
|
||||||
db.addGroup(txn, group1);
|
db.addGroup(txn, group1);
|
||||||
|
|
||||||
// Add a message to the second group
|
// Add a message to the second group
|
||||||
|
|||||||
Reference in New Issue
Block a user