diff options
author | Oran Agra <oran@redislabs.com> | 2021-10-04 12:11:02 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-04 12:11:02 +0300 |
commit | c5e6a6204c4cf57f85e7c83a9b4e99f1a7204fd2 (patch) | |
tree | 9f55ffb0f03b07391b4796331aabcb7881ba80ae /src/geo.c | |
parent | fba15850e5c31666e4c3560a3be7fd034fa7e2b6 (diff) | |
download | redis-c5e6a6204c4cf57f85e7c83a9b4e99f1a7204fd2.tar.gz |
Fix ziplist and listpack overflows and truncations (CVE-2021-32627, CVE-2021-32628) (#9589)
- fix possible heap corruption in ziplist and listpack resulting by trying to
allocate more than the maximum size of 4GB.
- prevent ziplist (hash and zset) from reaching size of above 1GB, will be
converted to HT encoding, that's not a useful size.
- prevent listpack (stream) from reaching size of above 1GB.
- XADD will start a new listpack if the new record may cause the previous
listpack to grow over 1GB.
- XADD will respond with an error if a single stream record is over 1GB
- List type (ziplist in quicklist) was truncating strings that were over 4GB,
now it'll respond with an error.
Co-authored-by: sundb <sundbcn@gmail.com>
Diffstat (limited to 'src/geo.c')
-rw-r--r-- | src/geo.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -797,7 +797,7 @@ void georadiusGeneric(client *c, int srcKeyIndex, int flags) { robj *zobj; zset *zs; int i; - size_t maxelelen = 0; + size_t maxelelen = 0, totelelen = 0; if (returned_items) { zobj = createZsetObject(); @@ -812,13 +812,14 @@ void georadiusGeneric(client *c, int srcKeyIndex, int flags) { size_t elelen = sdslen(gp->member); if (maxelelen < elelen) maxelelen = elelen; + totelelen += elelen; znode = zslInsert(zs->zsl,score,gp->member); serverAssert(dictAdd(zs->dict,gp->member,&znode->score) == DICT_OK); gp->member = NULL; } if (returned_items) { - zsetConvertToListpackIfNeeded(zobj,maxelelen); + zsetConvertToListpackIfNeeded(zobj,maxelelen,totelelen); setKey(c,c->db,storekey,zobj); decrRefCount(zobj); notifyKeyspaceEvent(NOTIFY_ZSET,flags & GEOSEARCH ? "geosearchstore" : "georadiusstore",storekey, |