From fe360f28fdad2f2d12a8d977e7265bad4b160faa Mon Sep 17 00:00:00 2001 From: akwizgran Date: Thu, 26 Nov 2020 13:45:58 +0000 Subject: [PATCH] Check that timer argument is legal before storing. --- .../briar/autodelete/AutoDeleteManagerImpl.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/briar-core/src/main/java/org/briarproject/briar/autodelete/AutoDeleteManagerImpl.java b/briar-core/src/main/java/org/briarproject/briar/autodelete/AutoDeleteManagerImpl.java index d00b515a8..ce83a3085 100644 --- a/briar-core/src/main/java/org/briarproject/briar/autodelete/AutoDeleteManagerImpl.java +++ b/briar-core/src/main/java/org/briarproject/briar/autodelete/AutoDeleteManagerImpl.java @@ -20,6 +20,8 @@ import org.briarproject.briar.api.autodelete.AutoDeleteManager; import javax.annotation.concurrent.Immutable; import javax.inject.Inject; +import static org.briarproject.briar.api.autodelete.AutoDeleteConstants.MAX_AUTO_DELETE_TIMER_MS; +import static org.briarproject.briar.api.autodelete.AutoDeleteConstants.MIN_AUTO_DELETE_TIMER_MS; import static org.briarproject.briar.api.autodelete.AutoDeleteConstants.NO_AUTO_DELETE_TIMER; import static org.briarproject.briar.autodelete.AutoDeleteConstants.GROUP_KEY_AUTO_DELETE_TIMER; @@ -83,6 +85,11 @@ class AutoDeleteManagerImpl @Override public void setAutoDeleteTimer(Transaction txn, ContactId c, long timer) throws DbException { + if (timer != NO_AUTO_DELETE_TIMER && + (timer < MIN_AUTO_DELETE_TIMER_MS || + timer > MAX_AUTO_DELETE_TIMER_MS)) { + throw new IllegalArgumentException(); + } try { Group g = getGroup(db.getContact(txn, c)); BdfDictionary meta = BdfDictionary.of(