commit redis for openSUSE:Factory

Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package redis for openSUSE:Factory checked in at 2021-03-02 12:25:42 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/redis (Old) and /work/SRC/openSUSE:Factory/.redis.new.2378 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "redis" Tue Mar 2 12:25:42 2021 rev:65 rq:874969 version:6.0.11 Changes: -------- --- /work/SRC/openSUSE:Factory/redis/redis.changes 2021-02-23 20:19:46.303622115 +0100 +++ /work/SRC/openSUSE:Factory/.redis.new.2378/redis.changes 2021-03-02 12:25:55.683342568 +0100 @@ -1,0 +2,26 @@ +Wed Feb 24 12:10:22 UTC 2021 - Andreas Stieger <andreas.stieger@gmx.de> + +- redis 6.0.11: + * CVE-2021-21309: Avoid 32-bit overflows when proto-max-bulk-len + is set high (boo#1182657) + * Fix handling of threaded IO and CLIENT PAUSE (failover), could + lead to data loss or a crash + * Fix the selection of a random element from large hash tables + * Fix broken protocol in client tracking tracking-redir-broken message + * XINFO able to access expired keys on a replica + * Fix broken protocol in redis-benchmark when used with -a or + --dbnum + * Avoid assertions (on older kernels) when testing arm64 CoW bug + * CONFIG REWRITE should honor umask settings + * Fix firstkey,lastkey,step in COMMAND command for some commands + * RM_ZsetRem: Delete key if empty, the bug could leave empty + zset keys + +------------------------------------------------------------------- +Wed Feb 24 11:42:17 UTC 2021 - Jan Zerebecki <jzerebecki@suse.com> + +- Switch systemd type of the sentinel service from notify to simple. This can + be reverted when updating to 6.2 which fixes + https://github.com/redis/redis/issues/7284 . + +------------------------------------------------------------------- Old: ---- redis-6.0.10.tar.gz New: ---- redis-6.0.11.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ redis.spec ++++++ --- /var/tmp/diff_new_pack.5RJ2n2/_old 2021-03-02 12:25:56.331343147 +0100 +++ /var/tmp/diff_new_pack.5RJ2n2/_new 2021-03-02 12:25:56.335343151 +0100 @@ -20,7 +20,7 @@ %define _log_dir %{_localstatedir}/log/%{name} %define _conf_dir %{_sysconfdir}/%{name} Name: redis -Version: 6.0.10 +Version: 6.0.11 Release: 0 Summary: Persistent key-value database License: BSD-3-Clause ++++++ redis-6.0.10.tar.gz -> redis-6.0.11.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/redis-6.0.10/.github/workflows/ci.yml new/redis-6.0.11/.github/workflows/ci.yml --- old/redis-6.0.10/.github/workflows/ci.yml 2021-01-12 15:25:37.000000000 +0100 +++ new/redis-6.0.11/.github/workflows/ci.yml 2021-02-23 00:35:37.000000000 +0100 @@ -13,7 +13,7 @@ run: make BUILD_TLS=yes - name: test run: | - sudo apt-get install tcl8.5 + sudo apt-get install tcl8.6 ./runtest --verbose - name: module api test run: ./runtest-moduleapi --verbose diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/redis-6.0.10/.github/workflows/daily.yml new/redis-6.0.11/.github/workflows/daily.yml --- old/redis-6.0.10/.github/workflows/daily.yml 2021-01-12 15:25:37.000000000 +0100 +++ new/redis-6.0.11/.github/workflows/daily.yml 2021-02-23 00:35:37.000000000 +0100 @@ -20,7 +20,7 @@ run: make - name: test run: | - sudo apt-get install tcl8.5 + sudo apt-get install tcl8.6 ./runtest --accurate --verbose - name: module api test run: ./runtest-moduleapi --verbose @@ -39,7 +39,7 @@ run: make MALLOC=libc - name: test run: | - sudo apt-get install tcl8.5 + sudo apt-get install tcl8.6 ./runtest --accurate --verbose - name: module api test run: ./runtest-moduleapi --verbose @@ -60,7 +60,7 @@ make 32bit - name: test run: | - sudo apt-get install tcl8.5 + sudo apt-get install tcl8.6 ./runtest --accurate --verbose - name: module api test run: | @@ -82,7 +82,7 @@ make BUILD_TLS=yes - name: test run: | - sudo apt-get install tcl8.5 tcl-tls + sudo apt-get install tcl8.6 tcl-tls ./utils/gen-test-certs.sh ./runtest --accurate --verbose --tls ./runtest --accurate --verbose @@ -110,7 +110,7 @@ - name: test run: | sudo apt-get update - sudo apt-get install tcl8.5 valgrind -y + sudo apt-get install tcl8.6 valgrind -y ./runtest --valgrind --verbose --clients 1 - name: module api test run: ./runtest-moduleapi --valgrind --verbose --clients 1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/redis-6.0.10/00-RELEASENOTES new/redis-6.0.11/00-RELEASENOTES --- old/redis-6.0.10/00-RELEASENOTES 2021-01-12 15:25:37.000000000 +0100 +++ new/redis-6.0.11/00-RELEASENOTES 2021-02-23 00:35:37.000000000 +0100 @@ -12,6 +12,34 @@ -------------------------------------------------------------------------------- ================================================================================ +Redis 6.0.11 Released Mon Feb 22 16:13:23 IST 2021 +================================================================================ + +Upgrade urgency: SECURITY if you use 32bit build of redis (see bellow), LOW +otherwise. + +Integer overflow on 32-bit systems (CVE-2021-21309): +Redis 4.0 or newer uses a configurable limit for the maximum supported bulk +input size. By default, it is 512MB which is a safe value for all platforms. +If the limit is significantly increased, receiving a large request from a client +may trigger several integer overflow scenarios, which would result with buffer +overflow and heap corruption. + +Bug fixes: +* Avoid 32-bit overflows when proto-max-bulk-len is set high (#8522) +* Fix handling of threaded IO and CLIENT PAUSE (failover), could lead to data loss or a crash (#8520) +* Fix the selection of a random element from large hash tables (#8133) +* Fix broken protocol in client tracking tracking-redir-broken message (#8456) +* XINFO able to access expired keys on a replica (#8436) +* Fix broken protocol in redis-benchmark when used with -a or --dbnum (#8486) +* Avoid assertions (on older kernels) when testing arm64 CoW bug (#8405) +* CONFIG REWRITE should honor umask settings (#8371) +* Fix firstkey,lastkey,step in COMMAND command for some commands (#8367) + +Modules: +* RM_ZsetRem: Delete key if empty, the bug could leave empty zset keys (#8453) + +================================================================================ Redis 6.0.10 Released Tue Jan 12 16:20:20 IST 2021 ================================================================================ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/redis-6.0.10/runtest-moduleapi new/redis-6.0.11/runtest-moduleapi --- old/redis-6.0.10/runtest-moduleapi 2021-01-12 15:25:37.000000000 +0100 +++ new/redis-6.0.11/runtest-moduleapi 2021-02-23 00:35:37.000000000 +0100 @@ -28,4 +28,5 @@ --single unit/moduleapi/keyspace_events \ --single unit/moduleapi/blockedclient \ --single unit/moduleapi/getkeys \ +--single unit/moduleapi/zset \ "${@}" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/redis-6.0.10/src/Makefile new/redis-6.0.11/src/Makefile --- old/redis-6.0.10/src/Makefile 2021-01-12 15:25:37.000000000 +0100 +++ new/redis-6.0.11/src/Makefile 2021-02-23 00:35:37.000000000 +0100 @@ -245,11 +245,11 @@ REDIS_SERVER_NAME=redis-server$(PROG_SUFFIX) REDIS_SENTINEL_NAME=redis-sentinel$(PROG_SUFFIX) -REDIS_SERVER_OBJ=adlist.o quicklist.o ae.o anet.o dict.o server.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o crc16.o endianconv.o slowlog.o scripting.o bio.o rio.o rand.o memtest.o crcspeed.o crc64.o bitops.o sentinel.o notify.o setproctitle.o blocked.o hyperloglog.o latency.o sparkline.o redis-check-rdb.o redis-check-aof.o geo.o lazyfree.o module.o evict.o expire.o geohash.o geohash_helper.o childinfo.o defrag.o siphash.o rax.o t_stream.o listpack.o localtime.o lolwut.o lolwut5.o lolwut6.o acl.o gopher.o tracking.o connection.o tls.o sha256.o timeout.o setcpuaffinity.o +REDIS_SERVER_OBJ=adlist.o quicklist.o ae.o anet.o dict.o server.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o crc16.o endianconv.o slowlog.o scripting.o bio.o rio.o rand.o memtest.o crcspeed.o crc64.o bitops.o sentinel.o notify.o setproctitle.o blocked.o hyperloglog.o latency.o sparkline.o redis-check-rdb.o redis-check-aof.o geo.o lazyfree.o module.o evict.o expire.o geohash.o geohash_helper.o childinfo.o defrag.o siphash.o rax.o t_stream.o listpack.o localtime.o lolwut.o lolwut5.o lolwut6.o acl.o gopher.o tracking.o connection.o tls.o sha256.o timeout.o setcpuaffinity.o mt19937-64.o REDIS_CLI_NAME=redis-cli$(PROG_SUFFIX) -REDIS_CLI_OBJ=anet.o adlist.o dict.o redis-cli.o zmalloc.o release.o ae.o crcspeed.o crc64.o siphash.o crc16.o +REDIS_CLI_OBJ=anet.o adlist.o dict.o redis-cli.o zmalloc.o release.o ae.o crcspeed.o crc64.o siphash.o crc16.o mt19937-64.o REDIS_BENCHMARK_NAME=redis-benchmark$(PROG_SUFFIX) -REDIS_BENCHMARK_OBJ=ae.o anet.o redis-benchmark.o adlist.o dict.o zmalloc.o siphash.o +REDIS_BENCHMARK_OBJ=ae.o anet.o redis-benchmark.o adlist.o dict.o zmalloc.o siphash.o mt19937-64.o REDIS_CHECK_RDB_NAME=redis-check-rdb$(PROG_SUFFIX) REDIS_CHECK_AOF_NAME=redis-check-aof$(PROG_SUFFIX) @@ -321,7 +321,7 @@ $(REDIS_BENCHMARK_NAME): $(REDIS_BENCHMARK_OBJ) $(REDIS_LD) -o $@ $^ ../deps/hiredis/libhiredis.a $(FINAL_LIBS) -dict-benchmark: dict.c zmalloc.c sds.c siphash.c +dict-benchmark: dict.c zmalloc.c sds.c siphash.c mt19937-64.c $(REDIS_CC) $(FINAL_CFLAGS) $^ -D DICT_BENCHMARK_MAIN -o $@ $(FINAL_LIBS) DEP = $(REDIS_SERVER_OBJ:%.o=%.d) $(REDIS_CLI_OBJ:%.o=%.d) $(REDIS_BENCHMARK_OBJ:%.o=%.d) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/redis-6.0.10/src/blocked.c new/redis-6.0.11/src/blocked.c --- old/redis-6.0.10/src/blocked.c 2021-01-12 15:25:37.000000000 +0100 +++ new/redis-6.0.11/src/blocked.c 2021-02-23 00:35:37.000000000 +0100 @@ -98,6 +98,9 @@ client *c; while (listLength(server.unblocked_clients)) { + /* If clients are paused we yield for now, since + * we don't want to process any commands later. */ + if (clientsArePaused()) return; ln = listFirst(server.unblocked_clients); serverAssert(ln != NULL); c = ln->value; @@ -109,6 +112,11 @@ * client is not blocked before to proceed, but things may change and * the code is conceptually more correct this way. */ if (!(c->flags & CLIENT_BLOCKED)) { + /* If we have a queued command, execute it now. */ + if (processPendingCommandsAndResetClient(c) == C_ERR) { + continue; + } + /* Then process client if it has more data in it's buffer. */ if (c->querybuf && sdslen(c->querybuf) > 0) { processInputBuffer(c); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/redis-6.0.10/src/config.c new/redis-6.0.11/src/config.c --- old/redis-6.0.10/src/config.c 2021-01-12 15:25:37.000000000 +0100 +++ new/redis-6.0.11/src/config.c 2021-02-23 00:35:37.000000000 +0100 @@ -1625,7 +1625,7 @@ if (fsync(fd)) serverLog(LL_WARNING, "Could not sync tmp config file to disk (%s)", strerror(errno)); - else if (fchmod(fd, 0644) == -1) + else if (fchmod(fd, 0644 & ~server.umask) == -1) serverLog(LL_WARNING, "Could not chmod config file (%s)", strerror(errno)); else if (rename(tmp_conffile, configfile) == -1) serverLog(LL_WARNING, "Could not rename tmp config file (%s)", strerror(errno)); @@ -2374,7 +2374,7 @@ createLongLongConfig("cluster-node-timeout", NULL, MODIFIABLE_CONFIG, 0, LLONG_MAX, server.cluster_node_timeout, 15000, INTEGER_CONFIG, NULL, NULL), createLongLongConfig("slowlog-log-slower-than", NULL, MODIFIABLE_CONFIG, -1, LLONG_MAX, server.slowlog_log_slower_than, 10000, INTEGER_CONFIG, NULL, NULL), createLongLongConfig("latency-monitor-threshold", NULL, MODIFIABLE_CONFIG, 0, LLONG_MAX, server.latency_monitor_threshold, 0, INTEGER_CONFIG, NULL, NULL), - createLongLongConfig("proto-max-bulk-len", NULL, MODIFIABLE_CONFIG, 1024*1024, LLONG_MAX, server.proto_max_bulk_len, 512ll*1024*1024, MEMORY_CONFIG, NULL, NULL), /* Bulk request max size */ + createLongLongConfig("proto-max-bulk-len", NULL, MODIFIABLE_CONFIG, 1024*1024, LONG_MAX, server.proto_max_bulk_len, 512ll*1024*1024, MEMORY_CONFIG, NULL, NULL), /* Bulk request max size */ createLongLongConfig("stream-node-max-entries", NULL, MODIFIABLE_CONFIG, 0, LLONG_MAX, server.stream_node_max_entries, 100, INTEGER_CONFIG, NULL, NULL), createLongLongConfig("repl-backlog-size", NULL, MODIFIABLE_CONFIG, 1, LLONG_MAX, server.repl_backlog_size, 1024*1024, MEMORY_CONFIG, NULL, updateReplBacklogSize), /* Default: 1mb */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/redis-6.0.10/src/dict.c new/redis-6.0.11/src/dict.c --- old/redis-6.0.10/src/dict.c 2021-01-12 15:25:37.000000000 +0100 +++ new/redis-6.0.11/src/dict.c 2021-02-23 00:35:37.000000000 +0100 @@ -621,15 +621,13 @@ do { /* We are sure there are no elements in indexes from 0 * to rehashidx-1 */ - h = d->rehashidx + (random() % (d->ht[0].size + - d->ht[1].size - - d->rehashidx)); + h = d->rehashidx + (randomULong() % (dictSlots(d) - d->rehashidx)); he = (h >= d->ht[0].size) ? d->ht[1].table[h - d->ht[0].size] : d->ht[0].table[h]; } while(he == NULL); } else { do { - h = random() & d->ht[0].sizemask; + h = randomULong() & d->ht[0].sizemask; he = d->ht[0].table[h]; } while(he == NULL); } @@ -695,7 +693,7 @@ maxsizemask = d->ht[1].sizemask; /* Pick a random point inside the larger table. */ - unsigned long i = random() & maxsizemask; + unsigned long i = randomULong() & maxsizemask; unsigned long emptylen = 0; /* Continuous empty entries so far. */ while(stored < count && maxsteps--) { for (j = 0; j < tables; j++) { @@ -720,7 +718,7 @@ if (he == NULL) { emptylen++; if (emptylen >= 5 && emptylen > count) { - i = random() & maxsizemask; + i = randomULong() & maxsizemask; emptylen = 0; } } else { @@ -1237,6 +1235,13 @@ start_benchmark(); for (j = 0; j < count; j++) { + dictEntry *de = dictGetRandomKey(dict); + assert(de != NULL); + } + end_benchmark("Accessing random keys"); + + start_benchmark(); + for (j = 0; j < count; j++) { sds key = sdsfromlonglong(rand() % count); key[0] = 'X'; dictEntry *de = dictFind(dict,key); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/redis-6.0.10/src/dict.h new/redis-6.0.11/src/dict.h --- old/redis-6.0.10/src/dict.h 2021-01-12 15:25:37.000000000 +0100 +++ new/redis-6.0.11/src/dict.h 2021-02-23 00:35:37.000000000 +0100 @@ -33,11 +33,14 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include <stdint.h> - #ifndef __DICT_H #define __DICT_H +#include "mt19937-64.h" +#include <limits.h> +#include <stdint.h> +#include <stdlib.h> + #define DICT_OK 0 #define DICT_ERR 1 @@ -147,6 +150,13 @@ #define dictSize(d) ((d)->ht[0].used+(d)->ht[1].used) #define dictIsRehashing(d) ((d)->rehashidx != -1) +/* If our unsigned long type can store a 64 bit number, use a 64 bit PRNG. */ +#if ULONG_MAX >= 0xffffffffffffffff +#define randomULong() ((unsigned long) genrand64_int64()) +#else +#define randomULong() random() +#endif + /* API */ dict *dictCreate(dictType *type, void *privDataPtr); int dictExpand(dict *d, unsigned long size); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/redis-6.0.10/src/module.c new/redis-6.0.11/src/module.c --- old/redis-6.0.10/src/module.c 2021-01-12 15:25:37.000000000 +0100 +++ new/redis-6.0.11/src/module.c 2021-02-23 00:35:37.000000000 +0100 @@ -2508,6 +2508,7 @@ if (key->value && key->value->type != OBJ_ZSET) return REDISMODULE_ERR; if (key->value != NULL && zsetDel(key->value,ele->ptr)) { if (deleted) *deleted = 1; + moduleDelKeyIfEmpty(key); } else { if (deleted) *deleted = 0; } @@ -2552,6 +2553,7 @@ /* Return the "End of range" flag value to signal the end of the iteration. */ int RM_ZsetRangeEndReached(RedisModuleKey *key) { + if (!key->value || key->value->type != OBJ_ZSET) return 1; return key->zer; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/redis-6.0.10/src/mt19937-64.c new/redis-6.0.11/src/mt19937-64.c --- old/redis-6.0.10/src/mt19937-64.c 1970-01-01 01:00:00.000000000 +0100 +++ new/redis-6.0.11/src/mt19937-64.c 2021-02-23 00:35:37.000000000 +0100 @@ -0,0 +1,187 @@ +/* + A C-program for MT19937-64 (2004/9/29 version). + Coded by Takuji Nishimura and Makoto Matsumoto. + + This is a 64-bit version of Mersenne Twister pseudorandom number + generator. + + Before using, initialize the state by using init_genrand64(seed) + or init_by_array64(init_key, key_length). + + Copyright (C) 2004, Makoto Matsumoto and Takuji Nishimura, + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. The names of its contributors may not be used to endorse or promote + products derived from this software without specific prior written + permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + References: + T. Nishimura, ``Tables of 64-bit Mersenne Twisters'' + ACM Transactions on Modeling and + Computer Simulation 10. (2000) 348--357. + M. Matsumoto and T. Nishimura, + ``Mersenne Twister: a 623-dimensionally equidistributed + uniform pseudorandom number generator'' + ACM Transactions on Modeling and + Computer Simulation 8. (Jan. 1998) 3--30. + + Any feedback is very welcome. + http://www.math.hiroshima-u.ac.jp/~m-mat/MT/emt.html + email: m-mat @ math.sci.hiroshima-u.ac.jp (remove spaces) +*/ + + +#include "mt19937-64.h" +#include <stdio.h> + +#define NN 312 +#define MM 156 +#define MATRIX_A 0xB5026F5AA96619E9ULL +#define UM 0xFFFFFFFF80000000ULL /* Most significant 33 bits */ +#define LM 0x7FFFFFFFULL /* Least significant 31 bits */ + + +/* The array for the state vector */ +static unsigned long long mt[NN]; +/* mti==NN+1 means mt[NN] is not initialized */ +static int mti=NN+1; + +/* initializes mt[NN] with a seed */ +void init_genrand64(unsigned long long seed) +{ + mt[0] = seed; + for (mti=1; mti<NN; mti++) + mt[mti] = (6364136223846793005ULL * (mt[mti-1] ^ (mt[mti-1] >> 62)) + mti); +} + +/* initialize by an array with array-length */ +/* init_key is the array for initializing keys */ +/* key_length is its length */ +void init_by_array64(unsigned long long init_key[], + unsigned long long key_length) +{ + unsigned long long i, j, k; + init_genrand64(19650218ULL); + i=1; j=0; + k = (NN>key_length ? NN : key_length); + for (; k; k--) { + mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 62)) * 3935559000370003845ULL)) + + init_key[j] + j; /* non linear */ + i++; j++; + if (i>=NN) { mt[0] = mt[NN-1]; i=1; } + if (j>=key_length) j=0; + } + for (k=NN-1; k; k--) { + mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 62)) * 2862933555777941757ULL)) + - i; /* non linear */ + i++; + if (i>=NN) { mt[0] = mt[NN-1]; i=1; } + } + + mt[0] = 1ULL << 63; /* MSB is 1; assuring non-zero initial array */ +} + +/* generates a random number on [0, 2^64-1]-interval */ +unsigned long long genrand64_int64(void) +{ + int i; + unsigned long long x; + static unsigned long long mag01[2]={0ULL, MATRIX_A}; + + if (mti >= NN) { /* generate NN words at one time */ + + /* if init_genrand64() has not been called, */ + /* a default initial seed is used */ + if (mti == NN+1) + init_genrand64(5489ULL); + + for (i=0;i<NN-MM;i++) { + x = (mt[i]&UM)|(mt[i+1]&LM); + mt[i] = mt[i+MM] ^ (x>>1) ^ mag01[(int)(x&1ULL)]; + } + for (;i<NN-1;i++) { + x = (mt[i]&UM)|(mt[i+1]&LM); + mt[i] = mt[i+(MM-NN)] ^ (x>>1) ^ mag01[(int)(x&1ULL)]; + } + x = (mt[NN-1]&UM)|(mt[0]&LM); + mt[NN-1] = mt[MM-1] ^ (x>>1) ^ mag01[(int)(x&1ULL)]; + + mti = 0; + } + + x = mt[mti++]; + + x ^= (x >> 29) & 0x5555555555555555ULL; + x ^= (x << 17) & 0x71D67FFFEDA60000ULL; + x ^= (x << 37) & 0xFFF7EEE000000000ULL; + x ^= (x >> 43); + + return x; +} + +/* generates a random number on [0, 2^63-1]-interval */ +long long genrand64_int63(void) +{ + return (long long)(genrand64_int64() >> 1); +} + +/* generates a random number on [0,1]-real-interval */ +double genrand64_real1(void) +{ + return (genrand64_int64() >> 11) * (1.0/9007199254740991.0); +} + +/* generates a random number on [0,1)-real-interval */ +double genrand64_real2(void) +{ + return (genrand64_int64() >> 11) * (1.0/9007199254740992.0); +} + +/* generates a random number on (0,1)-real-interval */ +double genrand64_real3(void) +{ + return ((genrand64_int64() >> 12) + 0.5) * (1.0/4503599627370496.0); +} + +#ifdef MT19937_64_MAIN +int main(void) +{ + int i; + unsigned long long init[4]={0x12345ULL, 0x23456ULL, 0x34567ULL, 0x45678ULL}, length=4; + init_by_array64(init, length); + printf("1000 outputs of genrand64_int64()\n"); + for (i=0; i<1000; i++) { + printf("%20llu ", genrand64_int64()); + if (i%5==4) printf("\n"); + } + printf("\n1000 outputs of genrand64_real2()\n"); + for (i=0; i<1000; i++) { + printf("%10.8f ", genrand64_real2()); + if (i%5==4) printf("\n"); + } + return 0; +} +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/redis-6.0.10/src/mt19937-64.h new/redis-6.0.11/src/mt19937-64.h --- old/redis-6.0.10/src/mt19937-64.h 1970-01-01 01:00:00.000000000 +0100 +++ new/redis-6.0.11/src/mt19937-64.h 2021-02-23 00:35:37.000000000 +0100 @@ -0,0 +1,87 @@ +/* + A C-program for MT19937-64 (2004/9/29 version). + Coded by Takuji Nishimura and Makoto Matsumoto. + + This is a 64-bit version of Mersenne Twister pseudorandom number + generator. + + Before using, initialize the state by using init_genrand64(seed) + or init_by_array64(init_key, key_length). + + Copyright (C) 2004, Makoto Matsumoto and Takuji Nishimura, + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. The names of its contributors may not be used to endorse or promote + products derived from this software without specific prior written + permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + References: + T. Nishimura, ``Tables of 64-bit Mersenne Twisters'' + ACM Transactions on Modeling and + Computer Simulation 10. (2000) 348--357. + M. Matsumoto and T. Nishimura, + ``Mersenne Twister: a 623-dimensionally equidistributed + uniform pseudorandom number generator'' + ACM Transactions on Modeling and + Computer Simulation 8. (Jan. 1998) 3--30. + + Any feedback is very welcome. + http://www.math.hiroshima-u.ac.jp/~m-mat/MT/emt.html + email: m-mat @ math.sci.hiroshima-u.ac.jp (remove spaces) +*/ + +#ifndef __MT19937_64_H +#define __MT19937_64_H + +/* initializes mt[NN] with a seed */ +void init_genrand64(unsigned long long seed); + +/* initialize by an array with array-length */ +/* init_key is the array for initializing keys */ +/* key_length is its length */ +void init_by_array64(unsigned long long init_key[], + unsigned long long key_length); + +/* generates a random number on [0, 2^64-1]-interval */ +unsigned long long genrand64_int64(void); + + +/* generates a random number on [0, 2^63-1]-interval */ +long long genrand64_int63(void); + +/* generates a random number on [0,1]-real-interval */ +double genrand64_real1(void); + +/* generates a random number on [0,1)-real-interval */ +double genrand64_real2(void); + +/* generates a random number on (0,1)-real-interval */ +double genrand64_real3(void); + +/* generates a random number on (0,1]-real-interval */ +double genrand64_real4(void); + +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/redis-6.0.10/src/networking.c new/redis-6.0.11/src/networking.c --- old/redis-6.0.10/src/networking.c 2021-01-12 15:25:37.000000000 +0100 +++ new/redis-6.0.11/src/networking.c 2021-02-23 00:35:37.000000000 +0100 @@ -1903,6 +1903,19 @@ return deadclient ? C_ERR : C_OK; } +/* This function will execute any fully parsed commands pending on + * the client. Returns C_ERR if the client is no longer valid after executing + * the command, and C_OK for all other cases. */ +int processPendingCommandsAndResetClient(client *c) { + if (c->flags & CLIENT_PENDING_COMMAND) { + c->flags &= ~CLIENT_PENDING_COMMAND; + if (processCommandAndResetClient(c) == C_ERR) { + return C_ERR; + } + } + return C_OK; +} + /* This function is called every time, in the client structure 'c', there is * more query buffer to process, because we read more data from the socket * or because a client was blocked and later reactivated, so there could be @@ -1911,7 +1924,9 @@ /* Keep processing while there is something in the input buffer */ while(c->qb_pos < sdslen(c->querybuf)) { /* Return if clients are paused. */ - if (!(c->flags & CLIENT_SLAVE) && clientsArePaused()) break; + if (!(c->flags & CLIENT_SLAVE) && + !(c->flags & CLIENT_PENDING_READ) && + clientsArePaused()) break; /* Immediately abort if the client is in the middle of something. */ if (c->flags & CLIENT_BLOCKED) break; @@ -3269,6 +3284,7 @@ int postponeClientRead(client *c) { if (server.io_threads_active && server.io_threads_do_reads && + !clientsArePaused() && !ProcessingEventsWhileBlocked && !(c->flags & (CLIENT_MASTER|CLIENT_SLAVE|CLIENT_PENDING_READ))) { @@ -3336,15 +3352,17 @@ client *c = listNodeValue(ln); c->flags &= ~CLIENT_PENDING_READ; listDelNode(server.clients_pending_read,ln); - - if (c->flags & CLIENT_PENDING_COMMAND) { - c->flags &= ~CLIENT_PENDING_COMMAND; - if (processCommandAndResetClient(c) == C_ERR) { - /* If the client is no longer valid, we avoid - * processing the client later. So we just go - * to the next. */ - continue; - } + /* Clients can become paused while executing the queued commands, + * so we need to check in between each command. If a pause was + * executed, we still remove the command and it will get picked up + * later when clients are unpaused and we re-queue all clients. */ + if (clientsArePaused()) continue; + + if (processPendingCommandsAndResetClient(c) == C_ERR) { + /* If the client is no longer valid, we avoid + * processing the client later. So we just go + * to the next. */ + continue; } processInputBuffer(c); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/redis-6.0.10/src/redis-benchmark.c new/redis-6.0.11/src/redis-benchmark.c --- old/redis-6.0.10/src/redis-benchmark.c 2021-01-12 15:25:37.000000000 +0100 +++ new/redis-6.0.11/src/redis-benchmark.c 2021-02-23 00:35:37.000000000 +0100 @@ -50,6 +50,7 @@ #include "zmalloc.h" #include "atomicvar.h" #include "crc16_slottable.h" +#include "mt19937-64.h" #define UNUSED(V) ((void) V) #define RANDPTR_INITIAL_SIZE 8 @@ -527,6 +528,9 @@ * we need to randomize. */ for (j = 0; j < c->randlen; j++) c->randptr[j] -= c->prefixlen; + /* Fix the pointers to the slot hash tags */ + for (j = 0; j < c->staglen; j++) + c->stagptr[j] -= c->prefixlen; c->prefixlen = 0; } continue; @@ -1520,7 +1524,8 @@ client c; - srandom(time(NULL)); + srandom(time(NULL) ^ getpid()); + init_genrand64(ustime() ^ getpid()); signal(SIGHUP, SIG_IGN); signal(SIGPIPE, SIG_IGN); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/redis-6.0.10/src/redis-check-rdb.c new/redis-6.0.11/src/redis-check-rdb.c --- old/redis-6.0.10/src/redis-check-rdb.c 2021-01-12 15:25:37.000000000 +0100 +++ new/redis-6.0.11/src/redis-check-rdb.c 2021-02-23 00:35:37.000000000 +0100 @@ -27,10 +27,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "mt19937-64.h" #include "server.h" #include "rdb.h" #include <stdarg.h> +#include <sys/time.h> +#include <unistd.h> void createSharedObjects(void); void rdbLoadProgressCallback(rio *r, const void *buf, size_t len); @@ -361,10 +364,16 @@ * Otherwise if called with a non NULL fp, the function returns C_OK or * C_ERR depending on the success or failure. */ int redis_check_rdb_main(int argc, char **argv, FILE *fp) { + struct timeval tv; + if (argc != 2 && fp == NULL) { fprintf(stderr, "Usage: %s <rdb-file-name>\n", argv[0]); exit(1); } + + gettimeofday(&tv, NULL); + init_genrand64(((long long) tv.tv_sec * 1000000 + tv.tv_usec) ^ getpid()); + /* In order to call the loading functions we need to create the shared * integer objects, however since this function may be called from * an already initialized Redis instance, check if we really need to. */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/redis-6.0.10/src/redis-cli.c new/redis-6.0.11/src/redis-cli.c --- old/redis-6.0.10/src/redis-cli.c 2021-01-12 15:25:37.000000000 +0100 +++ new/redis-6.0.11/src/redis-cli.c 2021-02-23 00:35:37.000000000 +0100 @@ -60,6 +60,7 @@ #include "help.h" #include "anet.h" #include "ae.h" +#include "mt19937-64.h" #define UNUSED(V) ((void) V) @@ -8066,6 +8067,7 @@ int main(int argc, char **argv) { int firstarg; + struct timeval tv; config.hostip = sdsnew("127.0.0.1"); config.hostport = 6379; @@ -8151,6 +8153,9 @@ } #endif + gettimeofday(&tv, NULL); + init_genrand64(((long long) tv.tv_sec * 1000000 + tv.tv_usec) ^ getpid()); + /* Cluster Manager mode */ if (CLUSTER_MANAGER_MODE()) { clusterManagerCommandProc *proc = validateClusterManagerCommand(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/redis-6.0.10/src/sds.c new/redis-6.0.11/src/sds.c --- old/redis-6.0.10/src/sds.c 2021-01-12 15:25:37.000000000 +0100 +++ new/redis-6.0.11/src/sds.c 2021-02-23 00:35:37.000000000 +0100 @@ -96,6 +96,7 @@ int hdrlen = sdsHdrSize(type); unsigned char *fp; /* flags pointer. */ + assert(initlen + hdrlen + 1 > initlen); /* Catch size_t overflow */ sh = s_malloc(hdrlen+initlen+1); if (sh == NULL) return NULL; if (init==SDS_NOINIT) @@ -214,6 +215,7 @@ len = sdslen(s); sh = (char*)s-sdsHdrSize(oldtype); newlen = (len+addlen); + assert(newlen > len); /* Catch size_t overflow */ if (newlen < SDS_MAX_PREALLOC) newlen *= 2; else @@ -227,6 +229,7 @@ if (type == SDS_TYPE_5) type = SDS_TYPE_8; hdrlen = sdsHdrSize(type); + assert(hdrlen + newlen + 1 > len); /* Catch size_t overflow */ if (oldtype==type) { newsh = s_realloc(sh, hdrlen+newlen+1); if (newsh == NULL) return NULL; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/redis-6.0.10/src/server.c new/redis-6.0.11/src/server.c --- old/redis-6.0.10/src/server.c 2021-01-12 15:25:37.000000000 +0100 +++ new/redis-6.0.11/src/server.c 2021-02-23 00:35:37.000000000 +0100 @@ -33,6 +33,7 @@ #include "bio.h" #include "latency.h" #include "atomicvar.h" +#include "mt19937-64.h" #include <time.h> #include <signal.h> @@ -427,11 +428,11 @@ {"zunionstore",zunionstoreCommand,-4, "write use-memory @sortedset", - 0,zunionInterGetKeys,0,0,0,0,0,0}, + 0,zunionInterGetKeys,1,1,1,0,0,0}, {"zinterstore",zinterstoreCommand,-4, "write use-memory @sortedset", - 0,zunionInterGetKeys,0,0,0,0,0,0}, + 0,zunionInterGetKeys,1,1,1,0,0,0}, {"zrange",zrangeCommand,-4, "read-only @sortedset", @@ -891,7 +892,7 @@ {"georadius_ro",georadiusroCommand,-6, "read-only @geo", - 0,georadiusGetKeys,1,1,1,0,0,0}, + 0,NULL,1,1,1,0,0,0}, {"georadiusbymember",georadiusbymemberCommand,-5, "write use-memory @geo", @@ -899,7 +900,7 @@ {"georadiusbymember_ro",georadiusbymemberroCommand,-5, "read-only @geo", - 0,georadiusGetKeys,1,1,1,0,0,0}, + 0,NULL,1,1,1,0,0,0}, {"geohash",geohashCommand,-2, "read-only @geo", @@ -955,11 +956,11 @@ {"xread",xreadCommand,-4, "read-only @stream @blocking", - 0,xreadGetKeys,1,1,1,0,0,0}, + 0,xreadGetKeys,0,0,0,0,0,0}, {"xreadgroup",xreadCommand,-7, "write @stream @blocking", - 0,xreadGetKeys,1,1,1,0,0,0}, + 0,xreadGetKeys,0,0,0,0,0,0}, {"xgroup",xgroupCommand,-2, "write use-memory @stream", @@ -4809,7 +4810,7 @@ FILE *f; f = fopen("/proc/self/smaps", "r"); - serverAssert(f); + if (!f) return -1; while (1) { if (!fgets(buf, sizeof(buf), f)) @@ -4820,8 +4821,8 @@ in_mapping = from <= addr && addr < to; if (in_mapping && !memcmp(buf, "Shared_Dirty:", 13)) { - ret = sscanf(buf, "%*s %d", &val); - serverAssert(ret == 1); + sscanf(buf, "%*s %d", &val); + /* If parsing fails, we remain with val == -1 */ break; } } @@ -4835,23 +4836,33 @@ * kernel is affected. * The bug was fixed in commit ff1712f953e27f0b0718762ec17d0adb15c9fd0b * titled: "arm64: pgtable: Ensure dirty bit is preserved across pte_wrprotect()" - * Return 1 if the kernel seems to be affected, and 0 otherwise. */ + * Return -1 on unexpected test failure, 1 if the kernel seems to be affected, + * and 0 otherwise. */ int linuxMadvFreeForkBugCheck(void) { - int ret, pipefd[2]; + int ret, pipefd[2] = { -1, -1 }; pid_t pid; - char *p, *q, bug_found = 0; - const long map_size = 3 * 4096; + char *p = NULL, *q; + int bug_found = 0; + long page_size = sysconf(_SC_PAGESIZE); + long map_size = 3 * page_size; /* Create a memory map that's in our full control (not one used by the allocator). */ p = mmap(NULL, map_size, PROT_READ, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); - serverAssert(p != MAP_FAILED); + if (p == MAP_FAILED) { + serverLog(LL_WARNING, "Failed to mmap(): %s", strerror(errno)); + return -1; + } - q = p + 4096; + q = p + page_size; /* Split the memory map in 3 pages by setting their protection as RO|RW|RO to prevent * Linux from merging this memory map with adjacent VMAs. */ - ret = mprotect(q, 4096, PROT_READ | PROT_WRITE); - serverAssert(!ret); + ret = mprotect(q, page_size, PROT_READ | PROT_WRITE); + if (ret < 0) { + serverLog(LL_WARNING, "Failed to mprotect(): %s", strerror(errno)); + bug_found = -1; + goto exit; + } /* Write to the page once to make it resident */ *(volatile char*)q = 0; @@ -4860,8 +4871,16 @@ #ifndef MADV_FREE #define MADV_FREE 8 #endif - ret = madvise(q, 4096, MADV_FREE); - serverAssert(!ret); + ret = madvise(q, page_size, MADV_FREE); + if (ret < 0) { + /* MADV_FREE is not available on older kernels that are presumably + * not affected. */ + if (errno == EINVAL) goto exit; + + serverLog(LL_WARNING, "Failed to madvise(): %s", strerror(errno)); + bug_found = -1; + goto exit; + } /* Write to the page after being marked for freeing, this is supposed to take * ownership of that page again. */ @@ -4869,37 +4888,47 @@ /* Create a pipe for the child to return the info to the parent. */ ret = pipe(pipefd); - serverAssert(!ret); + if (ret < 0) { + serverLog(LL_WARNING, "Failed to create pipe: %s", strerror(errno)); + bug_found = -1; + goto exit; + } /* Fork the process. */ pid = fork(); - serverAssert(pid >= 0); - if (!pid) { - /* Child: check if the page is marked as dirty, expecing 4 (kB). + if (pid < 0) { + serverLog(LL_WARNING, "Failed to fork: %s", strerror(errno)); + bug_found = -1; + goto exit; + } else if (!pid) { + /* Child: check if the page is marked as dirty, page_size in kb. * A value of 0 means the kernel is affected by the bug. */ - if (!smapsGetSharedDirty((unsigned long)q)) + ret = smapsGetSharedDirty((unsigned long) q); + if (!ret) bug_found = 1; + else if (ret == -1) /* Failed to read */ + bug_found = -1; - ret = write(pipefd[1], &bug_found, 1); - serverAssert(ret == 1); - + if (write(pipefd[1], &bug_found, sizeof(bug_found)) < 0) + serverLog(LL_WARNING, "Failed to write to parent: %s", strerror(errno)); exit(0); } else { /* Read the result from the child. */ - ret = read(pipefd[0], &bug_found, 1); - serverAssert(ret == 1); + ret = read(pipefd[0], &bug_found, sizeof(bug_found)); + if (ret < 0) { + serverLog(LL_WARNING, "Failed to read from child: %s", strerror(errno)); + bug_found = -1; + } /* Reap the child pid. */ - serverAssert(waitpid(pid, NULL, 0) == pid); + waitpid(pid, NULL, 0); } +exit: /* Cleanup */ - ret = close(pipefd[0]); - serverAssert(!ret); - ret = close(pipefd[1]); - serverAssert(!ret); - ret = munmap(p, map_size); - serverAssert(!ret); + if (pipefd[0] != -1) close(pipefd[0]); + if (pipefd[1] != -1) close(pipefd[1]); + if (p != NULL) munmap(p, map_size); return bug_found; } @@ -5312,8 +5341,15 @@ zmalloc_set_oom_handler(redisOutOfMemoryHandler); srand(time(NULL)^getpid()); gettimeofday(&tv,NULL); + init_genrand64(((long long) tv.tv_sec * 1000000 + tv.tv_usec) ^ getpid()); crc64_init(); + /* Store umask value. Because umask(2) only offers a set-and-get API we have + * to reset it and restore it back. We do this early to avoid a potential + * race condition with threads that could be creating files or directories. + */ + umask(server.umask = umask(0777)); + uint8_t hashseed[16]; getRandomBytes(hashseed,sizeof(hashseed)); dictSetHashFunctionSeed(hashseed); @@ -5445,10 +5481,17 @@ #ifdef __linux__ linuxMemoryWarnings(); #if defined (__arm64__) - if (linuxMadvFreeForkBugCheck()) { - serverLog(LL_WARNING,"WARNING Your kernel has a bug that could lead to data corruption during background save. Please upgrade to the latest stable kernel."); + int ret; + if ((ret = linuxMadvFreeForkBugCheck())) { + if (ret == 1) + serverLog(LL_WARNING,"WARNING Your kernel has a bug that could lead to data corruption during background save. " + "Please upgrade to the latest stable kernel."); + else + serverLog(LL_WARNING, "Failed to test the kernel for a bug that could lead to data corruption during background save. " + "Your system could be affected, please report this error."); if (!checkIgnoreWarning("ARM64-COW-BUG")) { - serverLog(LL_WARNING,"Redis will now exit to prevent data corruption. Note that it is possible to suppress this warning by setting the following config: ignore-warnings ARM64-COW-BUG"); + serverLog(LL_WARNING,"Redis will now exit to prevent data corruption. " + "Note that it is possible to suppress this warning by setting the following config: ignore-warnings ARM64-COW-BUG"); exit(1); } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/redis-6.0.10/src/server.h new/redis-6.0.11/src/server.h --- old/redis-6.0.10/src/server.h 2021-01-12 15:25:37.000000000 +0100 +++ new/redis-6.0.11/src/server.h 2021-02-23 00:35:37.000000000 +0100 @@ -1073,6 +1073,7 @@ int config_hz; /* Configured HZ value. May be different than the actual 'hz' field value if dynamic-hz is enabled. */ + mode_t umask; /* The umask value of the process on startup */ int hz; /* serverCron() calls frequency in hertz */ int in_fork_child; /* indication that this is a fork child */ redisDb *db; @@ -2020,6 +2021,7 @@ int freeMemoryIfNeeded(void); int freeMemoryIfNeededAndSafe(void); int processCommand(client *c); +int processPendingCommandsAndResetClient(client *c); void setupSignalHandlers(void); struct redisCommand *lookupCommand(sds name); struct redisCommand *lookupCommandByCString(const char *s); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/redis-6.0.10/src/t_stream.c new/redis-6.0.11/src/t_stream.c --- old/redis-6.0.10/src/t_stream.c 2021-01-12 15:25:37.000000000 +0100 +++ new/redis-6.0.11/src/t_stream.c 2021-02-23 00:35:37.000000000 +0100 @@ -2716,7 +2716,7 @@ key = c->argv[2]; /* Lookup the key now, this is common for all the subcommands but HELP. */ - robj *o = lookupKeyWriteOrReply(c,key,shared.nokeyerr); + robj *o = lookupKeyReadOrReply(c,key,shared.nokeyerr); if (o == NULL || checkType(c,o,OBJ_STREAM)) return; s = o->ptr; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/redis-6.0.10/src/tracking.c new/redis-6.0.11/src/tracking.c --- old/redis-6.0.10/src/tracking.c 2021-01-12 15:25:37.000000000 +0100 +++ new/redis-6.0.11/src/tracking.c 2021-02-23 00:35:37.000000000 +0100 @@ -218,7 +218,7 @@ * are unable to send invalidation messages to the redirected * connection, because the client no longer exist. */ if (c->resp > 2) { - addReplyPushLen(c,3); + addReplyPushLen(c,2); addReplyBulkCBuffer(c,"tracking-redir-broken",21); addReplyLongLong(c,c->client_tracking_redirection); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/redis-6.0.10/src/version.h new/redis-6.0.11/src/version.h --- old/redis-6.0.10/src/version.h 2021-01-12 15:25:37.000000000 +0100 +++ new/redis-6.0.11/src/version.h 2021-02-23 00:35:37.000000000 +0100 @@ -1,2 +1,2 @@ -#define REDIS_VERSION "6.0.10" -#define REDIS_VERSION_NUM 0x0006000a +#define REDIS_VERSION "6.0.11" +#define REDIS_VERSION_NUM 0x0006000b diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/redis-6.0.10/src/zmalloc.c new/redis-6.0.11/src/zmalloc.c --- old/redis-6.0.10/src/zmalloc.c 2021-01-12 15:25:37.000000000 +0100 +++ new/redis-6.0.11/src/zmalloc.c 2021-02-23 00:35:37.000000000 +0100 @@ -56,6 +56,12 @@ #endif #endif +#if PREFIX_SIZE > 0 +#define ASSERT_NO_SIZE_OVERFLOW(sz) assert((sz) + PREFIX_SIZE > (sz)) +#else +#define ASSERT_NO_SIZE_OVERFLOW(sz) +#endif + /* Explicitly override malloc/free etc when using tcmalloc. */ #if defined(USE_TCMALLOC) #define malloc(size) tc_malloc(size) @@ -96,6 +102,7 @@ static void (*zmalloc_oom_handler)(size_t) = zmalloc_default_oom; void *zmalloc(size_t size) { + ASSERT_NO_SIZE_OVERFLOW(size); void *ptr = malloc(size+PREFIX_SIZE); if (!ptr) zmalloc_oom_handler(size); @@ -114,6 +121,7 @@ * Currently implemented only for jemalloc. Used for online defragmentation. */ #ifdef HAVE_DEFRAG void *zmalloc_no_tcache(size_t size) { + ASSERT_NO_SIZE_OVERFLOW(size); void *ptr = mallocx(size+PREFIX_SIZE, MALLOCX_TCACHE_NONE); if (!ptr) zmalloc_oom_handler(size); update_zmalloc_stat_alloc(zmalloc_size(ptr)); @@ -128,6 +136,7 @@ #endif void *zcalloc(size_t size) { + ASSERT_NO_SIZE_OVERFLOW(size); void *ptr = calloc(1, size+PREFIX_SIZE); if (!ptr) zmalloc_oom_handler(size); @@ -142,6 +151,7 @@ } void *zrealloc(void *ptr, size_t size) { + ASSERT_NO_SIZE_OVERFLOW(size); #ifndef HAVE_MALLOC_SIZE void *realptr; #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/redis-6.0.10/tests/modules/Makefile new/redis-6.0.11/tests/modules/Makefile --- old/redis-6.0.10/tests/modules/Makefile 2021-01-12 15:25:37.000000000 +0100 +++ new/redis-6.0.11/tests/modules/Makefile 2021-02-23 00:35:37.000000000 +0100 @@ -25,6 +25,7 @@ auth.so \ keyspace_events.so \ blockedclient.so \ + zset.so \ getkeys.so diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/redis-6.0.10/tests/modules/zset.c new/redis-6.0.11/tests/modules/zset.c --- old/redis-6.0.10/tests/modules/zset.c 1970-01-01 01:00:00.000000000 +0100 +++ new/redis-6.0.11/tests/modules/zset.c 2021-02-23 00:35:37.000000000 +0100 @@ -0,0 +1,30 @@ +#include "redismodule.h" + +/* ZSET.REM key element + * + * Removes an occurrence of an element from a sorted set. Replies with the + * number of removed elements (0 or 1). + */ +int zset_rem(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { + if (argc != 3) return RedisModule_WrongArity(ctx); + RedisModule_AutoMemory(ctx); + int keymode = REDISMODULE_READ | REDISMODULE_WRITE; + RedisModuleKey *key = RedisModule_OpenKey(ctx, argv[1], keymode); + int deleted; + if (RedisModule_ZsetRem(key, argv[2], &deleted) == REDISMODULE_OK) + return RedisModule_ReplyWithLongLong(ctx, deleted); + else + return RedisModule_ReplyWithError(ctx, "ERR ZsetRem failed"); +} + +int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { + REDISMODULE_NOT_USED(argv); + REDISMODULE_NOT_USED(argc); + if (RedisModule_Init(ctx, "zset", 1, REDISMODULE_APIVER_1) == + REDISMODULE_OK && + RedisModule_CreateCommand(ctx, "zset.rem", zset_rem, "", + 1, 1, 1) == REDISMODULE_OK) + return REDISMODULE_OK; + else + return REDISMODULE_ERR; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/redis-6.0.10/tests/unit/moduleapi/zset.tcl new/redis-6.0.11/tests/unit/moduleapi/zset.tcl --- old/redis-6.0.10/tests/unit/moduleapi/zset.tcl 1970-01-01 01:00:00.000000000 +0100 +++ new/redis-6.0.11/tests/unit/moduleapi/zset.tcl 2021-02-23 00:35:37.000000000 +0100 @@ -0,0 +1,16 @@ +set testmodule [file normalize tests/modules/zset.so] + +start_server {tags {"modules"}} { + r module load $testmodule + + test {Module zset rem} { + r del k + r zadd k 100 hello 200 world + assert_equal 1 [r zset.rem k hello] + assert_equal 0 [r zset.rem k hello] + assert_equal 1 [r exists k] + # Check that removing the last element deletes the key + assert_equal 1 [r zset.rem k world] + assert_equal 0 [r exists k] + } +} ++++++ redis-sentinel@.service ++++++ --- /var/tmp/diff_new_pack.5RJ2n2/_old 2021-03-02 12:25:56.675343454 +0100 +++ /var/tmp/diff_new_pack.5RJ2n2/_new 2021-03-02 12:25:56.675343454 +0100 @@ -4,7 +4,7 @@ PartOf=redis-sentinel.target [Service] -Type=notify +Type=simple User=redis Group=redis PrivateTmp=true ++++++ redis.hashes ++++++ --- /var/tmp/diff_new_pack.5RJ2n2/_old 2021-03-02 12:25:56.727343501 +0100 +++ /var/tmp/diff_new_pack.5RJ2n2/_new 2021-03-02 12:25:56.727343501 +0100 @@ -112,4 +112,10 @@ hash redis-6.0.8.tar.gz sha256 04fa1fddc39bd1aecb6739dd5dd73858a3515b427acd1e2947a66dadce868d68 http://download.redis.io/releases/redis-6.0.8.tar.gz hash redis-5.0.10.tar.gz sha256 e30a5e7d1593a715cdda2a82deb90190816d06c9d1dc1ef5b36874878c683382 http://download.redis.io/releases/redis-5.0.10.tar.gz hash redis-6.0.9.tar.gz sha256 dc2bdcf81c620e9f09cfd12e85d3bc631c897b2db7a55218fd8a65eaa37f86dd http://download.redis.io/releases/redis-6.0.9.tar.gz -hash redis-6.0.10.tar.gz sha256 79bbb894f9dceb33ca699ee3ca4a4e1228be7fb5547aeb2f99d921e86c1285bd https://download.redis.io/releases/redis-6.0.10.tar.gz +hash redis-6.2-rc1.tar.gz sha256 92fc13f57b31cb6425c590b9c6b0bf611450f66b18fe92b9d5893b3a9760c438 http://download.redis.io/releases/redis-6.2-rc1.tar.gz +hash redis-6.0.10.tar.gz sha256 79bbb894f9dceb33ca699ee3ca4a4e1228be7fb5547aeb2f99d921e86c1285bd http://download.redis.io/releases/redis-6.0.10.tar.gz +hash redis-6.2-rc2.tar.gz sha256 7153bbbd751f61ea70e649e0d19be6e7e78da9864527d46d10519e9a03cb0924 http://download.redis.io/releases/redis-6.2-rc2.tar.gz +hash redis-6.2-rc3.tar.gz sha256 f35bba2af553fb58b2068ee581f316cefe0c00041e48fc944bd962e65777851c http://download.redis.io/releases/redis-6.2-rc3.tar.gz +hash redis-5.0.11.tar.gz sha256 418135c453a94aac24c24243b041fb978fcc3ea4e1e1f996c1d64b16ae6ac1aa http://download.redis.io/releases/redis-5.0.11.tar.gz +hash redis-6.2.0.tar.gz sha256 67d624c25d962bd68aff8812a135df85bad07556b8825f3bcd5b522a9932dbca http://download.redis.io/releases/redis-6.2.0.tar.gz +hash redis-6.0.11.tar.gz sha256 c927f2d110e88fda308526a1809a4d7dfcd004319f0de66d40a58a42aec23c5f http://download.redis.io/releases/redis-6.0.11.tar.gz
participants (1)
-
Source-Sync