Skip to content

Conversation

@deepakrn
Copy link
Contributor

The returned by are not null-terminated strings, but fixed-length buffers. However, expects a null-terminated string for the argument. This commit modifies in to copy the node ID into a null-terminated local buffer before passing it to , preventing potential undefined behavior.

The  returned by  are not null-terminated strings, but fixed-length buffers. However,  expects a null-terminated string for the  argument. This commit modifies  in  to copy the node ID into a null-terminated local buffer before passing it to , preventing potential undefined behavior.

Signed-off-by: Deepak Nandihalli <deepakrn@users.noreply.github.com>
@deepakrn
Copy link
Contributor Author

deepakrn commented Dec 15, 2025

The other options I see are:

  1. Have ValkeyModule_GetClusterNodesList return null terminated node ids so that they can be used as is for getting the individual node info by calling GetClusterNodeInfo
  2. Have GetClusterNodeInfo take in a non-null terminated node-id of length VALKEYMODULE_NODE_ID_LEN. This would mean that extracting the node id can't happen via strlen().

Both the above options would be breaking changes to the module APIs. So, my proposal is to simply have the hellocluster.c send null terminated node-id to GetClusterNodeInfo API.

cc - @murphyjacob4

@codecov
Copy link

codecov bot commented Dec 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.45%. Comparing base (51f871a) to head (4ac9f99).
⚠️ Report is 18 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #2933      +/-   ##
============================================
- Coverage     72.46%   72.45%   -0.01%     
============================================
  Files           129      129              
  Lines         70530    70530              
============================================
- Hits          51108    51106       -2     
- Misses        19422    19424       +2     

see 8 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zuiderkwast
Copy link
Contributor

  1. Have GetClusterNodeInfo take in a non-null terminated node-id of length VALKEYMODULE_NODE_ID_LEN. This would mean that extracting the node id can't happen via strlen().

Both the above options would be breaking changes to the module APIs.

Why is the second option a breaking change?

@deepakrn
Copy link
Contributor Author

deepakrn commented Jan 5, 2026

@zuiderkwast - that is a good point. If we change the logic to look for string of length VALKEYMODULE_NODE_ID_LEN instead of reading until NULL, it shouldn't break clients that send valid node IDs with null terminators. I'll make that change. Thanks for the callout!

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.

2 participants