Unverified Commit 11b071a2 authored by ranshid's avatar ranshid Committed by GitHub
Browse files

ACL DRYRUN does not validate the verified command args. (#10405)

As a result we segfault when parsing and matching the command keys.
parent a26cab9d
...@@ -2790,6 +2790,13 @@ setuser_cleanup: ...@@ -2790,6 +2790,13 @@ setuser_cleanup:
return; return;
} }
if ((cmd->arity > 0 && cmd->arity != c->argc-3) ||
(c->argc-3 < -cmd->arity))
{
addReplyErrorFormat(c,"wrong number of arguments for '%s' command", cmd->fullname);
return;
}
int idx; int idx;
int result = ACLCheckAllUserCommandPerm(u, cmd, c->argv + 3, c->argc - 3, &idx); int result = ACLCheckAllUserCommandPerm(u, cmd, c->argv + 3, c->argc - 3, &idx);
if (result != ACL_OK) { if (result != ACL_OK) {
......
...@@ -315,9 +315,9 @@ start_server {tags {"acl external:skip"}} { ...@@ -315,9 +315,9 @@ start_server {tags {"acl external:skip"}} {
r ACL setuser command-test +@all %R~read* %W~write* %RW~rw* r ACL setuser command-test +@all %R~read* %W~write* %RW~rw*
# Test migrate, which is marked with incomplete keys # Test migrate, which is marked with incomplete keys
assert_equal "OK" [r ACL DRYRUN command-test MIGRATE whatever whatever rw] assert_equal "OK" [r ACL DRYRUN command-test MIGRATE whatever whatever rw 0 500]
assert_equal "This user has no permissions to access the 'read' key" [r ACL DRYRUN command-test MIGRATE whatever whatever read] assert_equal "This user has no permissions to access the 'read' key" [r ACL DRYRUN command-test MIGRATE whatever whatever read 0 500]
assert_equal "This user has no permissions to access the 'write' key" [r ACL DRYRUN command-test MIGRATE whatever whatever write] assert_equal "This user has no permissions to access the 'write' key" [r ACL DRYRUN command-test MIGRATE whatever whatever write 0 500]
assert_equal "OK" [r ACL DRYRUN command-test MIGRATE whatever whatever "" 0 5000 KEYS rw] assert_equal "OK" [r ACL DRYRUN command-test MIGRATE whatever whatever "" 0 5000 KEYS rw]
assert_equal "This user has no permissions to access the 'read' key" [r ACL DRYRUN command-test MIGRATE whatever whatever "" 0 5000 KEYS read] assert_equal "This user has no permissions to access the 'read' key" [r ACL DRYRUN command-test MIGRATE whatever whatever "" 0 5000 KEYS read]
assert_equal "This user has no permissions to access the 'write' key" [r ACL DRYRUN command-test MIGRATE whatever whatever "" 0 5000 KEYS write] assert_equal "This user has no permissions to access the 'write' key" [r ACL DRYRUN command-test MIGRATE whatever whatever "" 0 5000 KEYS write]
...@@ -433,6 +433,19 @@ start_server {tags {"acl external:skip"}} { ...@@ -433,6 +433,19 @@ start_server {tags {"acl external:skip"}} {
assert_equal "This user has no permissions to access the 'otherchannel' channel" [r ACL DRYRUN test-channels spublish otherchannel foo] assert_equal "This user has no permissions to access the 'otherchannel' channel" [r ACL DRYRUN test-channels spublish otherchannel foo]
assert_equal "This user has no permissions to access the 'otherchannel' channel" [r ACL DRYRUN test-channels ssubscribe otherchannel foo] assert_equal "This user has no permissions to access the 'otherchannel' channel" [r ACL DRYRUN test-channels ssubscribe otherchannel foo]
} }
test {Test DRYRUN with wrong number of arguments} {
r ACL setuser test-dry-run +@all ~v*
assert_equal "OK" [r ACL DRYRUN test-dry-run SET v v]
catch {r ACL DRYRUN test-dry-run SET v} e
assert_equal "ERR wrong number of arguments for 'set' command" $e
catch {r ACL DRYRUN test-dry-run SET} e
assert_equal "ERR wrong number of arguments for 'set' command" $e
}
$r2 close $r2 close
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment