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
```
This commit is contained in:
Meir Shpilraien (Spielrein) 2022-01-18 10:29:52 +02:00 committed by GitHub
parent ae89958972
commit 51f9bed3dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -966,6 +966,8 @@ void functionLoadCommand(client *c) {
desc = c->argv[argc_pos++]->ptr;
continue;
}
addReplyErrorFormat(c, "Unknown option given: %s", (char*)next_arg->ptr);
return;
}
if (argc_pos >= c->argc) {

View File

@ -12,6 +12,13 @@ start_server {tags {"scripting"}} {
r fcall test 0
} {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} {
catch {
r function load LUA test [get_function_code test {return 'hello1'}]