This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 68b658431f7d0784ec8e564bf8fc048e5a71a467
Author: RĂ©mi KOWALSKI <[email protected]>
AuthorDate: Wed Nov 6 15:10:04 2019 +0100

    JAMES-2964 sanitize negative quota value when reading them from a DAO
---
 .../java/org/apache/james/mailbox/cassandra/quota/QuotaCodec.java | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git 
a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/QuotaCodec.java
 
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/QuotaCodec.java
index 85470cd..d68d104 100644
--- 
a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/QuotaCodec.java
+++ 
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/QuotaCodec.java
@@ -28,6 +28,7 @@ import org.apache.james.core.quota.QuotaValue;
 public class QuotaCodec {
 
     private static final long INFINITE = -1;
+    private static final long NO_RIGHT = 0L;
 
     static Long quotaValueToLong(QuotaValue<?> value) {
         if (value.isUnlimited()) {
@@ -51,6 +52,13 @@ public class QuotaCodec {
         if (value == INFINITE) {
             return Optional.of(infiniteValue);
         }
+        if (isInvalid(value)) {
+            return Optional.of(quotaFactory.apply(NO_RIGHT));
+        }
         return Optional.of(quotaFactory.apply(value));
     }
+
+    private static boolean isInvalid(Long value) {
+        return value < -1;
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to