summaryrefslogtreecommitdiff
path: root/src/db.c
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2010-08-23 17:06:38 +0200
committerantirez <antirez@gmail.com>2010-08-23 17:06:38 +0200
commitc91abdcd077f868a59290bc9d68fba3130a3121d (patch)
treef22ed4a2a2b35da0609424aa02103eb5e1f3bbab /src/db.c
parentcbce5171451eb53f1370aacc30decd74512347ac (diff)
downloadredis-c91abdcd077f868a59290bc9d68fba3130a3121d.tar.gz
Fixed overflow detection in argument to long convertion function in general, and in expire/ttl pairs specifically, addressing issue 54
Diffstat (limited to 'src/db.c')
-rw-r--r--src/db.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/db.c b/src/db.c
index 0dec95b1c..6d287d72c 100644
--- a/src/db.c
+++ b/src/db.c
@@ -514,15 +514,14 @@ void expireatCommand(redisClient *c) {
}
void ttlCommand(redisClient *c) {
- time_t expire;
- int ttl = -1;
+ time_t expire, ttl = -1;
expire = getExpire(c->db,c->argv[1]);
if (expire != -1) {
- ttl = (int) (expire-time(NULL));
+ ttl = (expire-time(NULL));
if (ttl < 0) ttl = -1;
}
- addReplySds(c,sdscatprintf(sdsempty(),":%d\r\n",ttl));
+ addReplyLongLong(c,(long long)ttl);
}
void persistCommand(redisClient *c) {