Skip to content

sanitize dump payload: fix crash with empty set with listpack encoding#11519

Merged
oranagra merged 2 commits intoredis:unstablefrom
enjoy-binbin:empty_set_listpack
Nov 20, 2022
Merged

sanitize dump payload: fix crash with empty set with listpack encoding#11519
oranagra merged 2 commits intoredis:unstablefrom
enjoy-binbin:empty_set_listpack

Conversation

@enjoy-binbin
Copy link
Contributor

@enjoy-binbin enjoy-binbin commented Nov 17, 2022

The following example will create an empty set (listpack encoding):

> RESTORE key 0
"\x14\x25\x25\x00\x00\x00\x00\x00\x02\x01\x82\x5F\x37\x03\x06\x01\x82\x5F\x35\x03\x82\x5F\x33\x03\x00\x01\x82\x5F\x31\x03\x82\x5F\x39\x03\x04\xA9\x08\x01\xFF\x0B\x00\xA3\x26\x49\xB4\x86\xB0\x0F\x41"
OK
> SCARD key
(integer) 0
> SRANDMEMBER key
Error: Server closed the connection

In the spirit of #9297, skip empty set when loading RDB_TYPE_SET_LISTPACK.
Introduced in #11290

The following example will create an empty set (listpack encoding):
```
> RESTORE key 0
"\x14\x25\x25\x00\x00\x00\x00\x00\x02\x01\x82\x5F\x37\x03\x06\x01\x82\x5F\x35\x03\x82\x5F\x33\x03\x00\x01\x82\x5F\x31\x03\x82\x5F\x39\x03\x04\xA9\x08\x01\xFF\x0B\x00\xA3\x26\x49\xB4\x86\xB0\x0F\x41"
OK
> SCARD key
(integer) 0
> SRANDMEMBER key
Error: Server closed the connection
```

Skip empty set when loading RDB_TYPE_SET_LISTPACK.
Introduced in redis#11290
Copy link
Contributor

@zuiderkwast zuiderkwast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, empty set. This makes sense! Thanks!

@zeekling
Copy link
Contributor

but i got this error:

127.0.0.1:6379> restore _key 0 "\x14\x25\x25\x00\x00\x00\x00\x00\x02\x01\x82\x5F\x37\x03\x06\x01\x82\x5F\x35\x03\x82\x5F\x33\x03\x00\x01\x82\x5F\x31\x03\x82\x5F\x39\x03\x04\xA9\x08\x01\xFF\x0B\x00\xA3\x26\x49\xB4\x86\xB0\x0F\x41"
(error) ERR DUMP payload version or checksum are wrong

@zuiderkwast
Copy link
Contributor

@zeekling The testcase disables checksum validation (debug set-skip-checksum-validation 1). This is what many other test cases do.

@madolson madolson changed the title santize dump payload: fix carsh with empty set with listpack encoding sanitize dump payload: fix crash with empty set with listpack encoding Nov 18, 2022
@oranagra oranagra merged commit 51887e6 into redis:unstable Nov 20, 2022
@enjoy-binbin enjoy-binbin deleted the empty_set_listpack branch November 20, 2022 15:35
madolson pushed a commit to madolson/redis that referenced this pull request Apr 19, 2023
redis#11519)

The following example will create an empty set (listpack encoding):
```
> RESTORE key 0
"\x14\x25\x25\x00\x00\x00\x00\x00\x02\x01\x82\x5F\x37\x03\x06\x01\x82\x5F\x35\x03\x82\x5F\x33\x03\x00\x01\x82\x5F\x31\x03\x82\x5F\x39\x03\x04\xA9\x08\x01\xFF\x0B\x00\xA3\x26\x49\xB4\x86\xB0\x0F\x41"
OK
> SCARD key
(integer) 0
> SRANDMEMBER key
Error: Server closed the connection
```

In the spirit of redis#9297, skip empty set when loading RDB_TYPE_SET_LISTPACK.
Introduced in redis#11290
enjoy-binbin added a commit to enjoy-binbin/redis that referenced this pull request Jul 31, 2023
redis#11519)

The following example will create an empty set (listpack encoding):
```
> RESTORE key 0
"\x14\x25\x25\x00\x00\x00\x00\x00\x02\x01\x82\x5F\x37\x03\x06\x01\x82\x5F\x35\x03\x82\x5F\x33\x03\x00\x01\x82\x5F\x31\x03\x82\x5F\x39\x03\x04\xA9\x08\x01\xFF\x0B\x00\xA3\x26\x49\xB4\x86\xB0\x0F\x41"
OK
> SCARD key
(integer) 0
> SRANDMEMBER key
Error: Server closed the connection
```

In the spirit of redis#9297, skip empty set when loading RDB_TYPE_SET_LISTPACK.
Introduced in redis#11290
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants