From 0381931b4c6acbbd1cbbaa6814defaea9fd33847 Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 15 Nov 2017 12:48:32 +0100 Subject: [PATCH] Streams: Update listpack to fix 32bit strings encoding error. Note that streams produced by XADD in previous broken versions having elements with 4096 bytes or more will be permanently broken and must be created again from scratch. Fix #4428 Fix #4349 --- src/listpack.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/listpack.c b/src/listpack.c index e2702b65c..6db4086e9 100644 --- a/src/listpack.c +++ b/src/listpack.c @@ -283,7 +283,7 @@ int lpEncodeGetType(unsigned char *ele, uint32_t size, unsigned char *intenc, ui } else { if (size < 64) *enclen = 1+size; else if (size < 4096) *enclen = 2+size; - else *enclen = 4+size; + else *enclen = 5+size; return LP_ENCODING_STRING; } } @@ -363,7 +363,7 @@ void lpEncodeString(unsigned char *buf, unsigned char *s, uint32_t len) { buf[2] = (len >> 8) & 0xff; buf[3] = (len >> 16) & 0xff; buf[4] = (len >> 24) & 0xff; - memcpy(buf+4,s,len); + memcpy(buf+5,s,len); } }