summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorOran Agra <oran@redislabs.com>2023-03-20 18:50:44 +0200
committerGitHub <noreply@github.com>2023-03-20 18:50:44 +0200
commit48e0d4788434833b47892fe9f3d91be7687f25c9 (patch)
treeec544420b2ecda685584badae147fcbe8232ed7b /tests
parentc91241451b5de214392028a4ce81adad8359e77f (diff)
downloadredis-48e0d4788434833b47892fe9f3d91be7687f25c9.tar.gz
Avoid assertion when MSETNX is used with the same key twice (CVE-2023-28425) (#11940)
Using the same key twice in MSETNX command would trigger an assertion. This reverts #11594 (introduced in Redis 7.0.8)
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/type/string.tcl9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/unit/type/string.tcl b/tests/unit/type/string.tcl
index a9fa894dc..b25a14f4c 100644
--- a/tests/unit/type/string.tcl
+++ b/tests/unit/type/string.tcl
@@ -234,6 +234,15 @@ start_server {tags {"string"}} {
list [r msetnx x1{t} xxx y2{t} yyy] [r get x1{t}] [r get y2{t}]
} {1 xxx yyy}
+ test {MSETNX with not existing keys - same key twice} {
+ r del x1{t}
+ list [r msetnx x1{t} xxx x1{t} yyy] [r get x1{t}]
+ } {1 yyy}
+
+ test {MSETNX with already existing keys - same key twice} {
+ list [r msetnx x1{t} xxx x1{t} zzz] [r get x1{t}]
+ } {0 yyy}
+
test "STRLEN against non-existing key" {
assert_equal 0 [r strlen notakey]
}