Skip to content

Commit

Permalink
Fix syncd crashing due to invalid length being used for string printing
Browse files Browse the repository at this point in the history
PR #801 added some code to convert binary strings to be printable
strings. However, one code path used the raw value of `len` without
sanity checking as the length of the string, when the `length()`
function should have been used instead.

Sample syncd backtrace:

```

(gdb) print *this
$22 = {temp = 0x55feeaced250 "*3\r\n$6\r\nSCRIPT\r\n$4\r\nLOAD\r\n$863\r\nlocal keys = redis.call('KEYS', KEYS[1])\nlocal n = table.getn(keys)\n\nfor i = 1, n do\n   if KEYS[2] == \"\" and KEYS[3] == \"1\" then\n      redis.call('DEL', keys[i])  \n   e"..., len = -355539936}
```

Fix this by using the `length()` function.

Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
  • Loading branch information
saiarcot895 committed Jul 28, 2023
1 parent 62e8d80 commit 5f71661
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion common/rediscommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ int RedisCommand::appendTo(redisContext *ctx) const

std::string RedisCommand::toPrintableString() const
{
return binary_to_printable(temp, len);
return binary_to_printable(temp, length());
}

const char *RedisCommand::c_str() const
Expand Down

0 comments on commit 5f71661

Please sign in to comment.