Skip to content

Fix binary safety of cluster key lookup functions#296

Open
bjosv wants to merge 2 commits intovalkey-io:mainfrom
bjosv:support-binary-safe-keys
Open

Fix binary safety of cluster key lookup functions#296
bjosv wants to merge 2 commits intovalkey-io:mainfrom
bjosv:support-binary-safe-keys

Conversation

@bjosv
Copy link
Copy Markdown
Collaborator

@bjosv bjosv commented Mar 23, 2026

valkeyClusterGetSlotByKey and valkeyClusterGetNodeByKey used strlen() to determine the key length,
which truncated keys containing embedded null bytes, resulting in incorrect slot calculations and node lookups.

Add an explicit keylen parameter so callers provide the actual key length, consistent with how the rest of the library handles binary-safe keys.

This is a breaking API change.

References:

bjosv added 2 commits March 23, 2026 11:03
valkeyClusterGetSlotByKey and valkeyClusterGetNodeByKey used strlen()
to determine the key length, which truncated keys containing embedded
null bytes, resulting in incorrect slot calculations and node lookups.

Add an explicit keylen parameter so callers provide the actual key
length, consistent with how the rest of the library handles
binary-safe keys.

This is a breaking API change.

Reference: https://valkey.io/topics/keyspace/

Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant