mirror of
https://github.com/fluencelabs/redis
synced 2025-06-15 10:11:21 +00:00
Fixed overflow detection in argument to long convertion function in general, and in expire/ttl pairs specifically, addressing issue 54
This commit is contained in:
@ -358,6 +358,8 @@ int getLongLongFromObject(robj *o, long long *target) {
|
||||
if (o->encoding == REDIS_ENCODING_RAW) {
|
||||
value = strtoll(o->ptr, &eptr, 10);
|
||||
if (eptr[0] != '\0') return REDIS_ERR;
|
||||
if (errno == ERANGE && (value == LLONG_MIN || value == LLONG_MAX))
|
||||
return REDIS_ERR;
|
||||
} else if (o->encoding == REDIS_ENCODING_INT) {
|
||||
value = (long)o->ptr;
|
||||
} else {
|
||||
@ -375,7 +377,7 @@ int getLongLongFromObjectOrReply(redisClient *c, robj *o, long long *target, con
|
||||
if (msg != NULL) {
|
||||
addReplySds(c, sdscatprintf(sdsempty(), "-ERR %s\r\n", msg));
|
||||
} else {
|
||||
addReplySds(c, sdsnew("-ERR value is not an integer\r\n"));
|
||||
addReplySds(c, sdsnew("-ERR value is not an integer or out of range\r\n"));
|
||||
}
|
||||
return REDIS_ERR;
|
||||
}
|
||||
|
Reference in New Issue
Block a user