summaryrefslogtreecommitdiff
path: root/src/t_string.c
diff options
context:
space:
mode:
authorsundb <sundbcn@gmail.com>2021-02-22 14:45:26 +0800
committerGitHub <noreply@github.com>2021-02-22 08:45:26 +0200
commit362f2a84bd67a1b65d810b064163e8432c79138e (patch)
tree3ddeab3639267165c54618f39b0653c9201d72f4 /src/t_string.c
parentd828f90c26bf796cb54d6622389e5c14fcc9cbf0 (diff)
downloadredis-362f2a84bd67a1b65d810b064163e8432c79138e.tar.gz
Improve overflow check of expire time (#8519)
When milliseconds == LLONG_MAX / 1000, *1000 will not overflow.
Diffstat (limited to 'src/t_string.c')
-rw-r--r--src/t_string.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/t_string.c b/src/t_string.c
index cdf69110f..3f73363e0 100644
--- a/src/t_string.c
+++ b/src/t_string.c
@@ -78,7 +78,7 @@ void setGenericCommand(client *c, int flags, robj *key, robj *val, robj *expire,
if (expire) {
if (getLongLongFromObjectOrReply(c, expire, &milliseconds, NULL) != C_OK)
return;
- if (milliseconds <= 0 || (unit == UNIT_SECONDS && milliseconds >= LLONG_MAX / 1000)) {
+ if (milliseconds <= 0 || (unit == UNIT_SECONDS && milliseconds > LLONG_MAX / 1000)) {
/* Negative value provided or multiplication is gonna overflow. */
addReplyErrorFormat(c, "invalid expire time in %s", c->cmd->name);
return;
@@ -344,7 +344,7 @@ void getexCommand(client *c) {
if (expire) {
if (getLongLongFromObjectOrReply(c, expire, &milliseconds, NULL) != C_OK)
return;
- if (milliseconds <= 0 || (unit == UNIT_SECONDS && milliseconds >= LLONG_MAX / 1000)) {
+ if (milliseconds <= 0 || (unit == UNIT_SECONDS && milliseconds > LLONG_MAX / 1000)) {
/* Negative value provided or multiplication is gonna overflow. */
addReplyErrorFormat(c, "invalid expire time in %s", c->cmd->name);
return;