Fix syncd crashing due to invalid length being used for string printing#806
Closed
saiarcot895 wants to merge 1 commit intosonic-net:masterfrom
Closed
Fix syncd crashing due to invalid length being used for string printing#806saiarcot895 wants to merge 1 commit intosonic-net:masterfrom
saiarcot895 wants to merge 1 commit intosonic-net:masterfrom
Conversation
PR sonic-net#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>
qiluo-msft
reviewed
Jul 28, 2023
| std::string RedisCommand::toPrintableString() const | ||
| { | ||
| return binary_to_printable(temp, len); | ||
| return binary_to_printable(temp, length()); |
Contributor
Contributor
Contributor
The return value is actually length or error code in concept, we need to translate it to proper In reply to: 1656337880 Refers to: common/rediscommand.cpp:34 in 5f71661. [](commit_id = 5f71661, deletion_comment = False) |
Contributor
Contributor
Author
|
Closing as #807 fixes the actual bug. This issue is due to mixing of binaries that had different struct sizes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR #801 added some code to convert binary strings to be printable strings. However, one code path used the raw value of
lenwithout sanity checking as the length of the string, when thelength()function should have been used instead.Sample syncd backtrace:
Fix this by using the
length()function.