diff --git a/src/networking.c b/src/networking.c index 476af38f939e9a8dade68b8cdca4d5665ed255b4..5beb933fa340c67573c9b9efb8526738b5a16916 100644 --- a/src/networking.c +++ b/src/networking.c @@ -868,6 +868,11 @@ int processInlineBuffer(redisClient *c) { aux = sdsnewlen(c->querybuf,querylen); argv = sdssplitargs(aux,&argc); sdsfree(aux); + if (argv == NULL) { + addReplyError(c,"Protocol error: unbalanced quotes in request"); + setProtocolError(c,0); + return REDIS_ERR; + } /* Newline from slaves can be used to refresh the last ACK time. * This is useful for a slave to ping back while loading a big diff --git a/tests/unit/protocol.tcl b/tests/unit/protocol.tcl index 1700e489249892cef011f2de340069c03760b58c..ac99c3abb476794368f2b6f85c11889efc52591a 100644 --- a/tests/unit/protocol.tcl +++ b/tests/unit/protocol.tcl @@ -60,6 +60,14 @@ start_server {tags {"protocol"}} { assert_error "*wrong*arguments*ping*" {r ping x y z} } + test "Unbalanced number of quotes" { + reconnect + r write "set \"\"\"test-key\"\"\" test-value\r\n" + r write "ping\r\n" + r flush + assert_error "*unbalanced*" {r read} + } + set c 0 foreach seq [list "\x00" "*\x00" "$\x00"] { incr c