Skip to content

RED-180951 RED-180027 fixing bugs and improving the code - #2003

Merged
gabsow merged 1 commit into
8.8from
lili_8.8_avivd
May 5, 2026
Merged

gabsow merged 1 commit into
8.8from
lili_8.8_avivd

Conversation

@AvivDavid23

@AvivDavid23 AvivDavid23 commented May 5, 2026 •

Copy link
Copy Markdown
Contributor

Made with Cursor


Note

Medium Risk
Touches RDB/RESTORE deserialization paths for both compressed and uncompressed chunks; while changes are defensive, mistakes could cause valid persisted data to fail loading.

Overview
Hardens RDB loading against corrupted payloads. Uncompressed_LoadFromRDB now validates num_samples vs. chunk capacity and requires the loaded buffer length to match the declared size; Compressed_LoadFromRDB now rejects zero-length buffers and ensures the stored bit index (idx) fits within the loaded buffer.

Improves portability of errdefer usage under clang. Introduces a __blocked macro (maps to __block on clang, empty on GCC) and applies it to series_rdb_load’s series variable to keep cleanup logic valid.

Adds regression tests for broken RDBs. New tests/flow/test_borken_rdb.py crafts truncated/corrupted DUMP payloads and asserts RESTORE fails with the expected errors, including invalid chunk metadata.

Reviewed by Cursor Bugbot for commit 98ad77c. Bugbot is set up for automated code reviews on this repo. Configure here.

@sonarqubecloud

sonarqubecloud Bot commented May 5, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
35.1% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@gabsow
gabsow merged commit 20149ee into 8.8 May 5, 2026
11 of 55 checks passed
@gabsow
gabsow deleted the lili_8.8_avivd branch May 5, 2026 05:23

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 98ad77c. Configure here.

Comment thread src/compressed_chunk.c
if (compchunk->idx > len * 8) {
err = true;
return TSDB_ERROR; /* Bit index can't exceed buffer size in bits */
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing size-buffer length validation in compressed chunk load

High Severity

The new validation in Compressed_LoadFromRDB checks len == 0 and compchunk->idx > len * 8 but does not validate that compchunk->size == len. In chunk.c, the equivalent check uncompchunk->size != string_buffer_size is present, but compressed_chunk.c is missing it. Since compchunk->size is used directly for serialization (saveStringBuffer reads compchunk->size bytes from compchunk->data) and buffer arithmetic, a crafted payload with compchunk->size > len causes a heap over-read.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 98ad77c. Configure here.


_patch_dump_crc(b)
assert _verify_dump_payload(bytes(b)), "patched DUMP payload should have valid checksum"
return bytes(b)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused helper function and dependencies are dead code

Low Severity

_patch_first_uncompressed_chunk_num_samples is defined but never called anywhere in the codebase. Since it's the sole caller of _verify_dump_payload, _patch_dump_crc, _rdb_load_len, _rdb_skip_string, _rdb_read_string_len_and_skip, and _crc_reflect64 / _redis_crc64, the entire chain of ~100 lines of helper code is unreachable dead code.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 98ad77c. Configure here.

YaacovHazan pushed a commit to redis/redis that referenced this pull request May 14, 2026
JSON - 8.7.91:
* Cherry-pick bug fixes to 8.8 (RedisJSON/RedisJSON#1557)
* MOD-6722 Fix mutation ordering for array commands with recursive paths
(RedisJSON/RedisJSON#1543)
* MOD-7266 make sure to end() deserialization, to disallow trailing c…
(RedisJSON/RedisJSON#1554)
* MOD-14664 Json Path evaluation - Allow multi-result nodelists in filt…
(RedisJSON/RedisJSON#1542)

Bloom - 8.7.91
* Lili: RED-180951 RED-181297 RED-184457 RED-184456 RED-184458
RED-184459 fixing bugs and improving the code
(RedisBloom/RedisBloom#1002)
* MOD-14675 - refresh os list to 8.8 (RedisBloom/RedisBloom#976)

Time Series - 8.7.91:
* MOD-15262 - Align TimeSeries with the RedisModule_GetUserUserName API…
(RedisTimeSeries/RedisTimeSeries#1985)
* MOD-14420 fix count reducers return wrong NaN
(RedisTimeSeries/RedisTimeSeries#2013)
(RedisTimeSeries/RedisTimeSeries#2016)
* Lili- RED-180951 RED-180027 fixing bugs and improving the code
(RedisTimeSeries/RedisTimeSeries#2003)
* MOD-14674 - refresh os list to 8.8
(RedisTimeSeries/RedisTimeSeries#1946)
hanzo-dev pushed a commit to hanzoai/redis that referenced this pull request Sep 11, 2026
JSON - 8.7.91:
* Cherry-pick bug fixes to 8.8 (RedisJSON/RedisJSON#1557)
* MOD-6722 Fix mutation ordering for array commands with recursive paths
(RedisJSON/RedisJSON#1543)
* MOD-7266 make sure to end() deserialization, to disallow trailing c…
(RedisJSON/RedisJSON#1554)
* MOD-14664 Json Path evaluation - Allow multi-result nodelists in filt…
(RedisJSON/RedisJSON#1542)

Bloom - 8.7.91
* Lili: RED-180951 RED-181297 RED-184457 RED-184456 RED-184458
RED-184459 fixing bugs and improving the code
(RedisBloom/RedisBloom#1002)
* MOD-14675 - refresh os list to 8.8 (RedisBloom/RedisBloom#976)

Time Series - 8.7.91:
* MOD-15262 - Align TimeSeries with the RedisModule_GetUserUserName API…
(RedisTimeSeries/RedisTimeSeries#1985)
* MOD-14420 fix count reducers return wrong NaN
(RedisTimeSeries/RedisTimeSeries#2013)
(RedisTimeSeries/RedisTimeSeries#2016)
* Lili- RED-180951 RED-180027 fixing bugs and improving the code
(RedisTimeSeries/RedisTimeSeries#2003)
* MOD-14674 - refresh os list to 8.8
(RedisTimeSeries/RedisTimeSeries#1946)
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