mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 00:28:26 -05:00
fix stream deep sanitization with deleted records (#8568)
When sanitizing the stream listpack, we need to count the deleted records too. otherwise the last line that checks the next pointer fails. Add test to cover that state in the stream tests.
This commit is contained in:
parent
a031d268b1
commit
349ef3f6a0
@ -3570,7 +3570,7 @@ int streamValidateListpackIntegrity(unsigned char *lp, size_t size, int deep) {
|
||||
p = next; if (!lpValidateNext(lp, &next, size)) return 0;
|
||||
|
||||
/* deleted */
|
||||
lpGetIntegerIfValid(p, &valid_record);
|
||||
int64_t deleted_count = lpGetIntegerIfValid(p, &valid_record);
|
||||
if (!valid_record) return 0;
|
||||
p = next; if (!lpValidateNext(lp, &next, size)) return 0;
|
||||
|
||||
@ -3589,6 +3589,7 @@ int streamValidateListpackIntegrity(unsigned char *lp, size_t size, int deep) {
|
||||
if (!valid_record || zero != 0) return 0;
|
||||
p = next; if (!lpValidateNext(lp, &next, size)) return 0;
|
||||
|
||||
entry_count += deleted_count;
|
||||
while (entry_count--) {
|
||||
if (!p) return 0;
|
||||
int64_t fields = master_fields, extra_fields = 3;
|
||||
|
@ -32,6 +32,7 @@ proc generate_types {} {
|
||||
# add some metadata to the stream
|
||||
r xgroup create stream mygroup 0
|
||||
set records [r xreadgroup GROUP mygroup Alice COUNT 2 STREAMS stream >]
|
||||
r xdel stream [lindex [lindex [lindex [lindex $records 0] 1] 1] 0]
|
||||
r xack stream mygroup [lindex [lindex [lindex [lindex $records 0] 1] 0] 0]
|
||||
|
||||
# create other non-collection types
|
||||
|
@ -52,6 +52,7 @@ start_server [list overrides [list "dir" $server_path] keep_persistence true] {
|
||||
}
|
||||
r xgroup create stream mygroup 0
|
||||
set records [r xreadgroup GROUP mygroup Alice COUNT 2 STREAMS stream >]
|
||||
r xdel stream [lindex [lindex [lindex [lindex $records 0] 1] 1] 0]
|
||||
r xack stream mygroup [lindex [lindex [lindex [lindex $records 0] 1] 0] 0]
|
||||
set digest [r debug digest]
|
||||
r config set sanitize-dump-payload no
|
||||
|
Loading…
Reference in New Issue
Block a user