12176 Commits

Author SHA1 Message Date
Huang Zhw
a3cb1bb0db redis-cli when SELECT fails, we should reset dbnum to 0 (#8898)
when SELECT fails, we should reset dbnum to 0, so the prompt will not
display incorrectly.

Additionally when SELECT and HELLO fail, we output message to inform
it.

Add config.input_dbnum which means the dbnum about to select.
And config.dbnum means currently selected dbnum. When users succeed to
select db, config.dbnum and config.input_dbnum will be the same. When
users select db failed, config.input_dbnum will be kept. Next time if users
auth success, config.input_dbnum will be automatically selected.
When reconnect, we should select the origin dbnum.

Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit 6b475989984bb28499327e33cc79315d6264bc06)
2021-10-04 13:59:40 +03:00
Binbin
9d66fb2d8b GEO* STORE with empty src key delete the dest key and return 0, not empty array (#9271)
With an empty src key, we need to deal with two situations:
1. non-STORE: We should return emptyarray.
2. STORE: Try to delete the store key and return 0.

This applies to both GEOSEARCHSTORE (new to v6.2), and
also GEORADIUS STORE (which was broken since forever)

This pr try to fix #9261. i.e. both STORE variants would have behaved
like the non-STORE variants when the source key was missing,
returning an empty array and not deleting the destination key,
instead of returning 0, and deleting the destination key.

Also add more tests for some commands.
- GEORADIUS: wrong type src key, non existing src key, empty search,
  store with non existing src key, store with empty search
- GEORADIUSBYMEMBER: wrong type src key, non existing src key,
  non existing member, store with non existing src key
- GEOSEARCH: wrong type src key, non existing src key, empty search,
  frommember with non existing member
- GEOSEARCHSTORE: wrong type key, non existing src key,
  fromlonlat with empty search, frommember with non existing member

Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit 86555ae0f7cc45abac7f758d72bf456e90793b46)
2021-10-04 13:59:40 +03:00
YiyuanGUO
1b3eace356 Fix integer overflow in _sdsMakeRoomFor (CVE-2021-41099) 2021-10-04 13:59:40 +03:00
Oran Agra
24977cdff6 Fix ziplist and listpack overflows and truncations (CVE-2021-32627, CVE-2021-32628)
- 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.
2021-10-04 13:59:40 +03:00
meir@redislabs.com
b7834ea6e4 Fix invalid memory write on lua stack overflow {CVE-2021-32626}
When LUA call our C code, by default, the LUA stack has room for 20
elements. In most cases, this is more than enough but sometimes it's not
and the caller must verify the LUA stack size before he pushes elements.

On 3 places in the code, there was no verification of the LUA stack size.
On specific inputs this missing verification could have lead to invalid
memory write:
1. On 'luaReplyToRedisReply', one might return a nested reply that will
   explode the LUA stack.
2. On 'redisProtocolToLuaType', the Redis reply might be deep enough
   to explode the LUA stack (notice that currently there is no such
   command in Redis that returns such a nested reply, but modules might
   do it)
3. On 'ldbRedis', one might give a command with enough arguments to
   explode the LUA stack (all the arguments will be pushed to the LUA
   stack)

This commit is solving all those 3 issues by calling 'lua_checkstack' and
verify that there is enough room in the LUA stack to push elements. In
case 'lua_checkstack' returns an error (there is not enough room in the
LUA stack and it's not possible to increase the stack), we will do the
following:
1. On 'luaReplyToRedisReply', we will return an error to the user.
2. On 'redisProtocolToLuaType' we will exit with panic (we assume this
   scenario is rare because it can only happen with a module).
3. On 'ldbRedis', we return an error.
2021-10-04 13:59:40 +03:00
meir@redislabs.com
73436d82a6 Fix protocol parsing on 'ldbReplParseCommand' (CVE-2021-32672)
The protocol parsing on 'ldbReplParseCommand' (LUA debugging)
Assumed protocol correctness. This means that if the following
is given:
*1
$100
test
The parser will try to read additional 94 unallocated bytes after
the client buffer.
This commit fixes this issue by validating that there are actually enough
bytes to read. It also limits the amount of data that can be sent by
the debugger client to 1M so the client will not be able to explode
the memory.
2021-10-04 13:59:40 +03:00
Oran Agra
c34f970be5 Prevent unauthenticated client from easily consuming lots of memory (CVE-2021-32675)
This change sets a low limit for multibulk and bulk length in the
protocol for unauthenticated connections, so that they can't easily
cause redis to allocate massive amounts of memory by sending just a few
characters on the network.
The new limits are 10 arguments of 16kb each (instead of 1m of 512mb)
2021-10-04 13:59:40 +03:00
Oran Agra
7cd645a043 Fix redis-cli / redis-sential overflow on some platforms (CVE-2021-32762)
The redis-cli command line tool and redis-sentinel service may be vulnerable
to integer overflow when parsing specially crafted large multi-bulk network
replies. This is a result of a vulnerability in the underlying hiredis
library which does not perform an overflow check before calling the calloc()
heap allocation function.

This issue only impacts systems with heap allocators that do not perform their
own overflow checks. Most modern systems do and are therefore not likely to
be affected. Furthermore, by default redis-sentinel uses the jemalloc allocator
which is also not vulnerable.
2021-10-04 13:59:40 +03:00
Oran Agra
59c94dedb2 Fix Integer overflow issue with intsets (CVE-2021-32687)
The vulnerability involves changing the default set-max-intset-entries
configuration parameter to a very large value and constructing specially
crafted commands to manipulate sets
2021-10-04 13:59:40 +03:00
Maxime de Roucy
d7efbd0c4e syslog: enforce syslog identity and facility as soon as possible
Former-commit-id: a9eaf0a130d3685c000d5f9cb500bb5f8cb8b263
2021-09-16 17:29:55 -04:00
Maxime de Roucy
3078d08c04 use LL_… log level instead of syslog LOG_… log level
Else there is an out of bound access in syslogLevelMap.

For example if we use `serverLog(LOG_INFO,…`, later in the code
it tries to access `syslogLevelMap[LOG_INFO]`.
LOG_INFO == 6 but syslogLevelMap only have 4 elements.


Former-commit-id: a1680fa612bdf5f521ea2c06b83994bf0797015a
2021-09-16 17:29:07 -04:00
benschermel
77ecd63dc2 update deb packaging to build with systemd flag
Former-commit-id: d7bd4f7a1c8d6195b60ccf6417ebb77fba097398
2021-09-08 02:28:17 +00:00
benschermel
eb9b09c311 update pkg conf file
Former-commit-id: 0be40b9fd43ec4e7802e09fa627ad91b2e387707
2021-08-22 22:21:34 +00:00
benschermel
b8bb658e47 update pkg conf file
Former-commit-id: 03a52dade1fe8cf5a10bbab113e14f73fade0373
2021-08-22 22:18:22 +00:00
MalavanEQAlpha
fd5f0b8ebe Merge pull request #313 from MalavanEQAlpha/fixissue295
Resolve Issue #295 by speeding up keyIsExpired and setting timeout on subkey expires.

Former-commit-id: 9e5e6c2f86548b18ae27b4e1ac20c72517392b07
2021-08-18 17:34:18 -04:00
malavan
67300040f7 should use LLONG_MAX for INVALID_EXPIRE not LLONG_MIN and add better comments
Former-commit-id: 1ab19b445f00a9ccdab13bf6b96363d068e2fa02
2021-08-18 20:59:01 +00:00
VivekSainiEQ
af217ab261 Include gperftools/tcmalloc.h instead of google/tcmalloc.h
Former-commit-id: ee32ed045cb94334773fc12d7b78a6a4ae29f184
2021-08-18 15:40:09 -04:00
John Sully
ae7a09c508 Solo tests should work with loopn
Former-commit-id: 82ba449dd0f8e8c81d7391241a6e75ada1bb314c
2021-08-18 15:08:10 -04:00
benschermel
cfc4ff96d3 add keydb-diagnostic-tool to packaging
Former-commit-id: 971725cc8c9a4592d3e63f53e3dd10b6ca27e72f
2021-08-16 23:21:07 +00:00
malavan
7686b09b39 Remove duplicate code
Former-commit-id: 9b7febb538f8a9f9aaa8e62732f7f85430b7fcd7
2021-08-16 22:55:46 +00:00
malavan
fd84a41aba don't use flags that aren't supported by certain versions of OPENSSL
Former-commit-id: fae6bfb80bc66351e278f8c5c4ce91bdcef64afb
2021-08-16 22:55:46 +00:00
benschermel
ad18db98b5 add keydb-diagnostic-tool to packaging
Former-commit-id: 45bb6e801f5249f11edd93423c5fd0d3d92d53b2
2021-08-16 22:10:31 +00:00
MalavanEQAlpha
908a0053d5 Merge pull request #344 from EQ-Alpha/fix_pbuild_ubuntu18.04
don't use flags that aren't supported by certain versions of OPENSSL

Former-commit-id: 1b73bc76c084c82682fa29cc9ac67880fa7e1ff9
2021-08-13 23:59:50 -04:00
malavan
3c157023bc don't use flags that aren't supported by certain versions of OPENSSL
Former-commit-id: 0bfd2ea8a66c20a006311e468b57f33ad21855f6
2021-08-13 20:02:06 +00:00
malavan
3da2de685c Merge branch 'RELEASE_6' of https://github.com/EQ-Alpha/KeyDB into RELEASE_6
Former-commit-id: 11c6d585ca0e2b9da2e9fef3faae459fa1ecfa57
2021-08-13 15:46:24 +00:00
malavan
7f8b58e376 Remove duplicate code
Former-commit-id: 2911145df7e007b7e6e5135745b732f3ac6a3e81
2021-08-13 15:46:09 +00:00
christianEQ
c89e0f711a install 32bit libraries in github action
Former-commit-id: b08aa26a765ddca4a398458ba6a3b91e0358aaf7
2021-08-13 11:05:12 -04:00
christianEQ
ef2c490b52 github runner for 32bit build
Former-commit-id: 8dacbed556e858e1ccaa567373bb1466ddabe91e
2021-08-13 11:05:12 -04:00
christianEQ
166faa8988 changed keys counter variable to unsigned to fix signedness comparison warning
Former-commit-id: b44df43fcbc6392796a9a2ec92b3aab1f43f5503
2021-08-13 11:05:12 -04:00
christianEQ
9b24998e1b %zu for printing type size_t
Former-commit-id: 84af829053eaf70439aaf0b7fdebfe2d9d2f3b6f
2021-08-13 11:05:12 -04:00
christianEQ
8d01244594 fixed 32bit compatibility in Makefile
Former-commit-id: f5ee64f9aaeb3f3773de2435191bcff0855154e4
2021-08-13 11:05:12 -04:00
christianEQ
cbf83d5eff fixed overly strict assert for 32bit
Former-commit-id: ce4891b33d65038bb0543eb2d3526c5310fee59b
2021-08-13 11:05:12 -04:00
benschermel
033fb4a612 update deb master changelog
Former-commit-id: afd8ac5c386bb2265974407cf0a422015ad2fcd9
2021-08-13 00:49:41 +00:00
benschermel
32e6ec97fe bump version
Former-commit-id: 7260ebf5c164fb779931723fabb66e48e9593385
2021-08-13 00:40:46 +00:00
malavan
5b115b56a1 bump version
Former-commit-id: aae676dc7d65df8f9e2f241a478be249e4ac422b
2021-08-11 23:23:39 +00:00
malavan
007bd5084b Merge remote-tracking branch 'origin/unstable' into RELEASE_6
Former-commit-id: 16897d36b8f8c297185fc54f93cfb705e88da131
2021-08-11 19:59:28 +00:00
MalavanEQAlpha
89d6d9632f Merge pull request #318 from VivekSainiEQ/redisearch_fixes
Initialized serverTL in more places in module.cpp

Former-commit-id: ffa46b8f0bd84c3f854a76e375be2108705fa8cc
2021-08-11 15:47:30 -04:00
Vivek Saini
8b013dc597 Merge pull request #296 from VivekSainiEQ/systemd_fix
Fixed bug where make USE_SYSTEMD=yes would not pass in correct flags

Former-commit-id: bf05c261d2689683ce89da2d062e1819ed6d772c
2021-08-11 15:39:50 -04:00
VivekSainiEQ
e0bdb4fca6 Merge remote-tracking branch 'upstream/unstable' into redisearch_fixes
Former-commit-id: 952ae9fbe38b99593ec175da6718a5d7fae49837
2021-08-11 19:28:04 +00:00
VivekSainiEQ
72e02159f4 Prevent invalid mvcc timestamps from causing critical errors
Former-commit-id: 6f2dbb00119b1d0a1f5a2543d2c6af05f83ef5de
2021-08-11 15:06:14 -04:00
Paweł Sacawa
39dccbbf21 Add: zsh completions with descriptions
This commit add zsh completions for the keydb `client`. They have contextual host completion and full argument descriptions.
Vendor-distributed completions for zsh should end up in `/usr/share/zsh/vendor-completions`, but unfortunatly I'm not familiar with the packaging method for *.deb archives, so these completions will need to be moved to the appropriate directory.


Former-commit-id: f77980fce87f22b59677e374e0d5c113775cc08a
2021-08-11 15:05:11 -04:00
MalavanEQAlpha
31cb587b27 Merge pull request #340 from EQ-Alpha/update_keydb.conf
update keydb.conf with new configs from redis unstable

Former-commit-id: d90c1e6eae9b0bb07fb67512e87339d948db5f72
2021-08-11 15:04:22 -04:00
MalavanEQAlpha
97a47446b8 Merge pull request #341 from EQ-Alpha/pkg_config
update packaging config files

Former-commit-id: d987f463ebeb19ed19869ebbed4e8681bcb6dbcb
2021-08-11 15:01:37 -04:00
benschermel
5a1a712ec6 add script to compare all active config parameters of any 2 config files
Former-commit-id: 89beaf2460e969c3ee18e03fe539de5833dba50a
2021-08-10 20:10:28 -04:00
benschermel
cc5528a8e2 update packaging config files
Former-commit-id: 0c5d12b91455db4acad57665db8aac79180b42ab
2021-08-10 20:08:39 -04:00
malavan
000e36f605 update keydb.conf with new configs from redis unstable
Former-commit-id: 32ca2e8a7335ee7bc4889a9369c97177f34739ee
2021-08-10 21:34:52 +00:00
malavan
0b752dd4e0 Merge branch 'unstable' into RELEASE_6
Former-commit-id: 470523573932200c82c3ac02fb26f99892789a3d
2021-08-09 18:17:11 +00:00
Christian Legge
7015a2abd2 Add REPLPING command for use during replication (#329)
* added replping command for initiating replication

* backwards compatibility for replping (retry if not recognized)

* don't allow ping during loading (load balancer fix)

* changed replping warning to notice

Former-commit-id: d7f6bc16145206e96ffeb9941398d564c3dba6a9
2021-07-29 15:50:30 -04:00
MalavanEQAlpha
7e08a9001c Merge pull request #328 from EQ-Alpha/backtrace_for_alpine
Backtrace for alpine using libunwind

Former-commit-id: 83d878f11183d8cd54fb34bceb7f839f73599ab1
2021-07-28 17:17:06 -04:00
malavan
54f40aff81 add some comments
Former-commit-id: 0fc6441c9608f0650003a7ab29dd704166345272
2021-07-28 20:32:18 +00:00