summaryrefslogtreecommitdiff
path: root/src/t_stream.c
diff options
context:
space:
mode:
authorOran Agra <oran@redislabs.com>2021-03-01 17:23:29 +0200
committerGitHub <noreply@github.com>2021-03-01 17:23:29 +0200
commit349ef3f6a0c6a1e351caabcc5ec57c8e49a0f4c8 (patch)
treee2e13862b8b1c82b6b2d202ecb40266e7cfd5508 /src/t_stream.c
parenta031d268b127d67969e9a4ec6b728dbb321ea0ce (diff)
downloadredis-349ef3f6a0c6a1e351caabcc5ec57c8e49a0f4c8.tar.gz
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.
Diffstat (limited to 'src/t_stream.c')
-rw-r--r--src/t_stream.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/t_stream.c b/src/t_stream.c
index 4a425fd78..18138bec5 100644
--- a/src/t_stream.c
+++ b/src/t_stream.c
@@ -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;