Commit 2da784ce authored by Pieter Noordhuis's avatar Pieter Noordhuis
Browse files

Abort on invalid format

There is no way we can guess the width of the argument when we cannot
infer its type from the format specifier.
parent 27c96dde
...@@ -826,10 +826,8 @@ int redisvFormatCommand(char **target, const char *format, va_list ap) { ...@@ -826,10 +826,8 @@ int redisvFormatCommand(char **target, const char *format, va_list ap) {
} }
fmt_invalid: fmt_invalid:
/* Consume and discard vararg */
va_arg(ap,void);
va_end(_cpy); va_end(_cpy);
break; goto err;
fmt_valid: fmt_valid:
_l = (_p+1)-c; _l = (_p+1)-c;
......
...@@ -162,11 +162,9 @@ static void test_format_commands(void) { ...@@ -162,11 +162,9 @@ static void test_format_commands(void) {
len == 4+4+(8+2)+4+(3+2)); len == 4+4+(8+2)+4+(3+2));
free(cmd); free(cmd);
test("Format command with wrong printf format and extra interpolation: "); test("Format command with invalid printf format: ");
len = redisFormatCommand(&cmd,"key:%08p %b",1234,"foo",3); len = redisFormatCommand(&cmd,"key:%08p %b",1234,"foo",3);
test_cond(strncmp(cmd,"*2\r\n$6\r\nkey:8p\r\n$3\r\nfoo\r\n",len) == 0 && test_cond(len == -1);
len == 4+4+(6+2)+4+(3+2));
free(cmd);
const char *argv[3]; const char *argv[3];
argv[0] = "SET"; argv[0] = "SET";
......
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