diff options
author | zhaozhao.zz <zhaozhao.zz@alibaba-inc.com> | 2018-07-18 00:12:24 +0800 |
---|---|---|
committer | zhaozhao.zz <zhaozhao.zz@alibaba-inc.com> | 2018-08-01 10:31:27 +0800 |
commit | da6b7516f187b85e7f9a8a2390f02e9c1dc2c7aa (patch) | |
tree | 88582c43e23a1bfe95af62a394af616f3ab19678 | |
parent | 20c6a7fe2c134ad21bfc4ce50e548c3a055e93d0 (diff) | |
download | redis-da6b7516f187b85e7f9a8a2390f02e9c1dc2c7aa.tar.gz |
Streams: XTRIM will return an error if MAXLEN with a count < 0
-rw-r--r-- | src/t_stream.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/t_stream.c b/src/t_stream.c index 5814aa132..bab5b74ff 100644 --- a/src/t_stream.c +++ b/src/t_stream.c @@ -2192,7 +2192,7 @@ void xtrimCommand(client *c) { /* Argument parsing. */ int trim_strategy = TRIM_STRATEGY_NONE; - long long maxlen = 0; /* 0 means no maximum length. */ + long long maxlen = -1; /* If left to -1 no trimming is performed. */ int approx_maxlen = 0; /* If 1 only delete whole radix tree nodes, so the maxium length is not applied verbatim. */ @@ -2211,6 +2211,11 @@ void xtrimCommand(client *c) { } if (getLongLongFromObjectOrReply(c,c->argv[i+1],&maxlen,NULL) != C_OK) return; + + if (maxlen < 0) { + addReplyError(c,"The MAXLEN argument must be >= 0."); + return; + } i++; } else { addReply(c,shared.syntaxerr); |