summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOran Agra <oran@redislabs.com>2021-09-26 18:46:22 +0300
committerGitHub <noreply@github.com>2021-09-26 18:46:22 +0300
commit5a4ab7c7d2da1773c5ed3dcfc6e367b5af03a33e (patch)
treeb903974bde3801ca8181b97f1e3d6910272b5bca
parent66002530466a45bce85e4930364f1b153c44840b (diff)
downloadredis-5a4ab7c7d2da1773c5ed3dcfc6e367b5af03a33e.tar.gz
Fix stream sanitization for non-int first value (#9553)
This was recently broken in #9321 when we validated stream IDs to be integers but did that after to the stepping next record instead of before.
-rw-r--r--src/t_stream.c2
-rw-r--r--tests/integration/rdb.tcl2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/t_stream.c b/src/t_stream.c
index 4fa562417..1968475fa 100644
--- a/src/t_stream.c
+++ b/src/t_stream.c
@@ -3603,12 +3603,12 @@ int streamValidateListpackIntegrity(unsigned char *lp, size_t size, int deep) {
p = next; if (!lpValidateNext(lp, &next, size)) return 0;
/* entry id */
- p = next; if (!lpValidateNext(lp, &next, size)) return 0;
lpGetIntegerIfValid(p, &valid_record);
if (!valid_record) return 0;
p = next; if (!lpValidateNext(lp, &next, size)) return 0;
lpGetIntegerIfValid(p, &valid_record);
if (!valid_record) return 0;
+ p = next; if (!lpValidateNext(lp, &next, size)) return 0;
if (!(flags & STREAM_ITEM_FLAG_SAMEFIELDS)) {
/* num-of-fields */
diff --git a/tests/integration/rdb.tcl b/tests/integration/rdb.tcl
index 938076456..9b5f12328 100644
--- a/tests/integration/rdb.tcl
+++ b/tests/integration/rdb.tcl
@@ -45,7 +45,7 @@ start_server [list overrides [list "dir" $server_path] keep_persistence true] {
test {Test RDB stream encoding} {
for {set j 0} {$j < 1000} {incr j} {
if {rand() < 0.9} {
- r xadd stream * foo $j
+ r xadd stream * foo abc
} else {
r xadd stream * bar $j
}