Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5528297

Browse files
committed
Not all versions contain the trailing NULL byte, so do not require it
1 parent 3266b22 commit 5528297

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

library.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2159,16 +2159,19 @@ redis_unserialize(RedisSock* redis_sock, const char *val, int val_len,
21592159
/*
21602160
* Check if the given string starts with an igbinary header.
21612161
*
2162-
* An igbinary string consists of the following format:
2162+
* A modern igbinary string consists of the following format:
21632163
*
21642164
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
21652165
* | header (4) | type (1) | ... (n) | NUL (1) |
21662166
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
21672167
*
21682168
* With header being either 0x00000001 or 0x00000002
21692169
* (encoded as big endian).
2170+
*
2171+
* Not all versions contain the trailing NULL byte though, so
2172+
* do not check for that.
21702173
*/
2171-
if (val_len < 6
2174+
if (val_len < 5
21722175
|| (memcmp(val, "\x00\x00\x00\x01", 4) != 0
21732176
&& memcmp(val, "\x00\x00\x00\x02", 4) != 0))
21742177
{

0 commit comments

Comments
 (0)