Unverified Commit 51f9bed3 authored by Meir Shpilraien (Spielrein)'s avatar Meir Shpilraien (Spielrein) Committed by GitHub
Browse files

Fix `FUNCTION LOAD` ignores unknown parameter. (#10131)

Following discussion on: https://github.com/redis/redis/issues/9899#issuecomment-1014689385
Raise error if unknows parameter is given to `FUNCTION LOAD`.

Before the fix:
```
127.0.0.1:6379> function load LUA lib2 foo bar "local function test1() return 5 end redis.register_function('test1', test1)"
OK
```

After the fix:
```
127.0.0.1:6379> function load LUA lib2 foo bar "local function test1() return 5 end redis.register_function('test1', test1)"
(error) ERR Unkowns option given: foo
```
parent ae899589
...@@ -966,6 +966,8 @@ void functionLoadCommand(client *c) { ...@@ -966,6 +966,8 @@ void functionLoadCommand(client *c) {
desc = c->argv[argc_pos++]->ptr; desc = c->argv[argc_pos++]->ptr;
continue; continue;
} }
addReplyErrorFormat(c, "Unknown option given: %s", (char*)next_arg->ptr);
return;
} }
if (argc_pos >= c->argc) { if (argc_pos >= c->argc) {
......
...@@ -12,6 +12,13 @@ start_server {tags {"scripting"}} { ...@@ -12,6 +12,13 @@ start_server {tags {"scripting"}} {
r fcall test 0 r fcall test 0
} {hello} } {hello}
test {FUNCTION - Load with unknown argument} {
catch {
r function load LUA test foo bar [get_function_code test {return 'hello'}]
} e
set _ $e
} {*Unknown option given*}
test {FUNCTION - Create an already exiting library raise error} { test {FUNCTION - Create an already exiting library raise error} {
catch { catch {
r function load LUA test [get_function_code test {return 'hello1'}] r function load LUA test [get_function_code test {return 'hello1'}]
......
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