Validate slot import ranges in valkey-check-rdb when checking slot RDB - #4470
Validate slot import ranges in valkey-check-rdb when checking slot RDB#4470enjoy-binbin wants to merge 1 commit into
Conversation
The runtime RDB load path (clusterRDBLoadSlotImport) already rejects slot import ranges where start/end >= CLUSTER_SLOTS or start > end, but valkey-check-rdb only read the lengths without validating them. Add the same range validation so check-rdb can detect such malformed RDB files instead of silently passing them. Follow up to valkey-io#4229. Signed-off-by: Binbin <binloveplay1314@qq.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughRDB slot-import parsing now stores both range endpoints, validates them against ChangesRDB slot-import validation
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This localized change adds validation for malformed slot import ranges in RDB checking, preventing invalid files from passing silently; no actionable merge-blocking risk remains. Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| uint64_t start_slot, end_slot; | ||
| if ((start_slot = rdbLoadLen(rdb, NULL)) == RDB_LENERR) goto eoferr; | ||
| if ((end_slot = rdbLoadLen(rdb, NULL)) == RDB_LENERR) goto eoferr; | ||
| if (start_slot >= CLUSTER_SLOTS || end_slot >= CLUSTER_SLOTS || start_slot > end_slot) { |
There was a problem hiding this comment.
tests/integration/rdb-slot-import.tcl already crafts RDB_OPCODE_SLOT_IMPORT records and runs VALKEY_CHECK_RDB_BIN, but this PR adds no case that reaches this check. Extend that fixture with start_slot == CLUSTER_SLOTS, end_slot == CLUSTER_SLOTS, and start_slot > end_slot, asserting each reports Invalid slot import range and does not report RDB looks OK.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## unstable #4470 +/- ##
============================================
+ Coverage 78.73% 78.78% +0.05%
============================================
Files 170 170
Lines 89783 89794 +11
============================================
+ Hits 70692 70748 +56
+ Misses 19091 19046 -45
🚀 New features to boost your workflow:
|
The runtime RDB load path (clusterRDBLoadSlotImport) already rejects
slot import ranges where start/end >= CLUSTER_SLOTS or start > end, but
valkey-check-rdb only read the lengths without validating them.
Add the same range validation so check-rdb can detect such malformed RDB
files instead of silently passing them.
Follow up to #4229.