From 87c74dfaa81d204d47ca9ae9e3f76ea521ca8460 Mon Sep 17 00:00:00 2001
From: Pieter Noordhuis <pcnoordhuis@gmail.com>
Date: Fri, 20 Aug 2010 13:42:42 +0200
Subject: [PATCH] Check if stroll return value was clamped

---
 src/object.c            | 1 +
 tests/unit/type/set.tcl | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/src/object.c b/src/object.c
index 45dde52b..b16123eb 100644
--- a/src/object.c
+++ b/src/object.c
@@ -375,6 +375,7 @@ int getLongLongFromObject(robj *o, long long *target) {
         redisAssert(o->type == REDIS_STRING);
         if (o->encoding == REDIS_ENCODING_RAW) {
             value = strtoll(o->ptr, &eptr, 10);
+            if (errno == ERANGE) return REDIS_ERR;
             if (eptr[0] != '\0') return REDIS_ERR;
         } else if (o->encoding == REDIS_ENCODING_INT) {
             value = (long)o->ptr;
diff --git a/tests/unit/type/set.tcl b/tests/unit/type/set.tcl
index a1b655ef..056ed27c 100644
--- a/tests/unit/type/set.tcl
+++ b/tests/unit/type/set.tcl
@@ -45,6 +45,12 @@ start_server {
         assert_encoding hashtable myset
     }
 
+    test "SADD an integer larger than 64 bits" {
+        create_set myset {213244124402402314402033402}
+        assert_encoding hashtable myset
+        assert_equal 1 [r sismember myset 213244124402402314402033402]
+    }
+
     test "SADD overflows the maximum allowed integers in an intset" {
         r del myset
         for {set i 0} {$i < 512} {incr i} { r sadd myset $i }
-- 
2.47.2