Fix Null Bulk String response parsing in cluster library #1104
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.
This PR fixes an issue when running LUA commands that don't return any values in a cluster context. In these cases, Redis will return a Null Bulk String as specified in the protocol:
Right now, this case is not handled and it causes and immediate Segmentation fault, because the RETVAL_STRINGL is trying to make sense of a bulk string response with no length at all. The issue is easily reproducible: just pick the failing test commit and run the test against your cluster. You should see an immediate Segmentation fault.
The issue is solved by returning a NULL value when the length is -1, as specified in the Redis protocol documentation.
Maintainers of this repository will probably know a better and more proper way of solving this issue, but here is my two-cents.
Props to @ajdiaz and @josledp for helping to find this issue!