Fix RM_ScanKey module api not to return int encoded strings#7396
Merged
antirez merged 1 commit intoredis:unstablefrom Jun 15, 2020
Merged
Fix RM_ScanKey module api not to return int encoded strings#7396antirez merged 1 commit intoredis:unstablefrom
antirez merged 1 commit intoredis:unstablefrom
Conversation
The scan key module API provides the scan callback with the current field name and value (if it exists). Those arguments are RedisModuleString* which means it supposes to point to robj which is encoded as a string. Using createStringObjectFromLongLong function might return robj that points to an integer and so break a module that tries for example to use RedisModule_StringPtrLen on the given field/value. The PR introduces a fix that uses the createObject function and sdsfromlonglong function. Using those function promise that the field and value pass to the to the scan callback will be Strings. The PR also changes the Scan test module to use RedisModule_StringPtrLen to catch the issue. without this, the issue is hidden because RedisModule_ReplyWithString knows to handle integer encoding of the given robj (RedisModuleString). The PR also introduces a new test to verify the issue is solved.
Contributor
|
Thanks @MeirShpilraien |
Author
|
@antirez sure. |
Contributor
|
Absolutely, I'll import every change before the next release.
…On Mon, Jun 15, 2020 at 1:37 PM Meir Shpilraien (Spielrein) < ***@***.***> wrote:
@antirez <https://github.com/antirez> sure.
Any chance we can cherry-pick it to Redis 6?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<https://github.com/antirez/redis/pull/7396#issuecomment-644075453>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAQAYAYM2QS5UFLMEMJDE3RWYBWNANCNFSM4N5LD7SQ>
.
--
Salvatore 'antirez' Sanfilippo
open source developer - Redis Labs https://redislabs.com
"If a system is to have conceptual integrity, someone must control the
concepts."
— Fred Brooks, "The Mythical Man-Month", 1975.
|
JackieXie168
pushed a commit
to JackieXie168/redis
that referenced
this pull request
Jun 18, 2020
…e_api Fix RM_ScanKey module api not to return int encoded strings
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.
The scan key module API provides the scan callback with the current
field name and value (if it exists). Those arguments are RedisModuleString*
which means it supposes to point to robj which is encoded as a string.
Using createStringObjectFromLongLong function might return robj that
points to an integer and so break a module that tries for example to
use RedisModule_StringPtrLen on the given field/value.
The PR introduces a fix that uses the createObject function and sdsfromlonglong function.
Using those function promise that the field and value pass to the to the
scan callback will be Strings.
The PR also changes the Scan test module to use RedisModule_StringPtrLen
to catch the issue. without this, the issue is hidden because
RedisModule_ReplyWithString knows to handle integer encoding of the
given robj (RedisModuleString).
The PR also introduces a new test to verify the issue is solved.