summaryrefslogtreecommitdiff
path: root/test.c
AgeCommit message (Collapse)Author
2022-11-02CI fixes in preparation of releasemichael-grunder
- Upgrade to actions/checkout@v3 as node 12 is being phased out. - Perform a manual dnf refresh on RockyLinux during setup. - Switch to official cygwin/cygwin-install-action
2022-10-14Fixup of PR734: Coverage of hiredis.c (#1124)Bjorn Svensson
Improve coverage (#734) * Remove duplicate tests - double covered by: "Can parse RESP3 doubles" - bool covered via: "Can parse RESP3 bool" * Make (connect) timeout in test config general * Set error string in Unix connect with invalid timeout Restructure testcase since redisConnectWithTimeout() and redisConnectUnixWithTimeout() now behaves similar. * Use quiet flag in lcov/genhtml instead of piping to /dev/null * Fixup of redisCommandArgv test case * Update test case to match what it covers Use new test case info text since the previous one seemed copy&pasted. The sought coverage was the handling of the parent-chaining for a double object, which the test case now focuses on. Co-authored-by: Ariel <ashtul@gmail.com>
2022-09-27Fix PUSH handler tests for Redis >= 7.0.5michael-grunder
Redis updated how invalidation push messages are sent to the client after a FLUSHDB or FLUSHALL command. See: redis/redis#8935
2022-09-08Minor refactormichael-grunder
Protect against a NULL pointer dereference, and remove unused write to a variable.
2022-09-03Use a windows specific keepalive function. (#1104)Michael Grunder
Use a windows specific keepalive function. While it is possible to toggle `TCP_KEEPALIVE` in windows via setsockopt, you have to use `WSAIoctl` to set the interval. Since `WSAIoctl` can actually do all of this in one call (toggle the option, and set the corresponding interval), just use that in Windows and avoid the call to `setsockopt` alltogether. Fixes: #1100
2022-09-01Fix heap-buffer-overflow issue in redisvFormatCommadBjörn Svensson
A command with a faulty formatting string that lacks the conversion specifier results in a ASAN heap-buffer-overflow. This was due to that strchr() matches on null-termination, which triggers a continuation of the string parsing.
2022-08-31Regression test for off-by-one parsing errorbugwz
See: #916
2022-08-29Rework asSleep to be a generic millisleep function.michael-grunder
2022-08-29Do store command timeout in the context for redisSetTimeout (#593)Arseniy Simonov
2022-08-29Merge pull request #901 from devnexen/illumos_test_fixMichael Grunder
Illumos test fixes, error message difference fot bad hostname test.
2022-08-26Maintain backward compatibiliy withour onConnect callback.michael-grunder
In f69fac7690fb22a7fc19dba61ef70e5f79ccb2e9, our async onConnect callback was improved to take a non-const redisAsyncContext allowing it to be reentrant. Unfortunately, this is a breaking change we can't make until hiredis v2.0.0. This commit creates a separate callback member and corresponding function that allows us to use the new functionality, while maintaining our existing API for legacy code. Fixes #1086
2022-07-08Drop `const` on redisAsyncContext in redisConnectCallbackKristján Valur Jónsson
Since the callback is now re-entrant, it can call apis such as redisAsyncDisconnect()
2022-07-08Add async regression test for issue #931Kristján Valur Jónsson
2022-07-05Add regression test for issue #945Kristján Valur Jónsson
2022-07-05Initial async testsKristján Valur Jónsson
2022-04-22Handle push notifications before or after reply.Yossi Gottlieb
2022-02-03Handle any pipelined unsubscribe in asyncBjörn Svensson
Redis responds to an unsubscribe with one or many replies, depending on the current subscribe state. When channels/patterns names are provided in a command each given name will trigger a reply even if duplicated or not subscribed to. To know when we can return from the subscribed state we need to do bookkeeping on pending additional unsubscribe replies, and make sure we receive them all before switching state.
2022-02-02Ignore pubsub replies without a channel/patternBjörn Svensson
2022-01-27Avoid incorrect call to the previous reply's callback (#1040)Bjorn Svensson
* No reuse of the previous reply callback When multiple replies are parsed from a socket in one read a previously found callback might get reused when the current reply has no known callback. This can be triggered by the added testcase which unsubscribe to subscribed (A,B) and a non-subscribed channel (X). Without this correction a callback for wrong channel is called. - In 'unsubscribe B X A', B's callback is called when handling X. - Now this is not done, i.e. there is no callback called for X. * Re-push monitor callback for each reply MONITORING used the same callback for all replies while parsing multiple responses. This handling was changed to avoid calling the wrong callback in some scenarios. Now also change monitorings repush to work with this change. Includes an added async monitoring testcase.
2022-01-18Allow sending commands after sending an unsubscribe (#1036)Bjorn Svensson
* Add test of async commands after unsubscribe Verify that commands are handled after unsubscribing from a channel. A command is sent before the `unsubscribe` response is received, which currently triggers an assert in async.c:567: `redisProcessCallbacks: Assertion `(c->flags & REDIS_SUBSCRIBED || c->flags & REDIS_MONITORING)' failed.` * Handle async commands after an unsubscribe When unsubscribing from the last channel we move from the `subscribe` state to a normal state. These states uses different holders for the command callback information. By moving the callback info during the state change the callback order can be maintained.
2022-01-11Correction for command timeout during pubsub (#1038)Bjorn Svensson
* Add test of command timeout during pubsub A timeout of a non-subscribe command will be ignored during pubsub. It will be handled as an idle timeout and a response is awaited for. * Correction for command timeout during pubsub Disconnect when a sent non-subscribe command triggers a timeout.
2021-12-22Handle array response in parallell with pubsub using RESP3 (#1014)Bjorn Svensson
RESP3 allows sending commands in parallell with pubsub handling and these commands might get responded with a REDIS_REPLY_ARRAY. This conflicts with the pubsub response handling for RESP2 and results in a faulty state when using RESP3. Add functionality to keep track of PUSH/RESP3 support on the connection and only expect the message type REDIS_REPLY_PUSH as subscribe messages when once seen.
2021-12-16Support PING while subscribing (RESP2) (#1027)Bjorn Svensson
* Handle PING during pubsub in RESP2 * Rename invalid callback list Some commands are valid to send during a subscribe in RESP2, and most in RESP3. Renaming the callback list from `invalid` to `replies` to detail this fact. * Fix review comment
2021-12-01Add asynchronous test for pubsub using RESP3 (#1012)Bjorn Svensson
* Include `unsubscribe` as a subscribe reply in RESP3 By providing the (p)unsubscribe message via the subscribe callback, instead of via the push callback, we get the same behavior in RESP3 as in RESP2. * Add asynchronous test for pubsub using RESP3 The testcase will subscribe to a channel, and via a second client a message is published to the channel. After receiving the message the testcase will unsubscribe and disconnect. This RESP3 testcase reuses the subscribe callback from the RESP2 testcase to make sure we have a common behavior.
2021-11-17Small tweaks of the async testsmichael-grunder
2021-10-27Add asynchronous test for pubsub using RESP2Björn Svensson
The testcase will subscribe to a channel, and via a second client a message is published to the channel. After receiving the message the testcase will unsubscribe and disconnect.
2021-10-10Fix unused variable warning.michael-grunder
2021-10-10Minor refactor of CVE-2021-32765 fix.michael-grunder
Since `hi_calloc` always passes through one of our wrapper functions, we can perform this overflow in the wrapper, and get protection everywhere. Previous commit: 76a7b10005c70babee357a7d0f2becf28ec7ed1e Related vuln ID: CVE-2021-32765 [Full Details](https://github.com/redis/hiredis/security/advisories/GHSA-hfm9-39pp-55p2)
2021-10-04Merge branch 'release/v1.0.1'michael-grunder
Merge the v1.0.1 release branch and bump the dev version to 1.0.2-dev
2021-10-04Fix for integer/buffer overflow CVE-2021-32765Yossi Gottlieb
This fix prevents hiredis from trying to allocate more than `SIZE_MAX` bytes, which would result in a buffer overrun. [Full Details](https://github.com/redis/hiredis/security/advisories/GHSA-hfm9-39pp-55p2)
2021-02-25read: Add support for the RESP3 bignum typeAlex Smith
2021-02-25read: Additional validation and test case for RESP3 doubleAlex Smith
This ensures that malformed RESP3 double messages that include an invalid null byte are not parsed as valid.
2021-02-25test: Add test case for RESP3 setAlex Smith
2021-02-25test: Add test case for RESP3 mapAlex Smith
2021-02-25test: Add test cases for RESP3 boolAlex Smith
2021-02-25test: Add test cases for RESP3 nilAlex Smith
2021-02-25test: Add test cases for infinite and NaN doublesAlex Smith
2021-02-25test: Add test case for doublesAlex Smith
2020-12-07Illumos test fixes, error message difference fot bad hostname test.David Carlier
2020-10-17Fix handling of NIL invalidation messages.michael-grunder
When CLIENT TRACKING is enabled, Redis will send an invalidation message with a NIL payload to all tracking clients after a FLUSHDB is executed. We didn't account for REDIS_REPLY_PUSH being a valid parent object to a NIL payload, and were failing an assertion. Additionally this commit adds a regression test for the logic.
2020-07-29Move SSL management to a distinct private pointer. (#855)Michael Grunder
We need to allow our users to use redisContext->privdata as context for any RESP3 PUSH messages, which means we can't use it for managing SSL connections. Bulletpoints: * Create a secondary redisContext member for internal use only called privctx and rename the redisContextFuncs->free_privdata accordingly. * Adds a `free_privdata` function pointer so the user can tie allocated memory to the lifetime of a redisContext (like they can already do with redisAsyncContext) * Enables SSL tests in .travis.yml
2020-07-19Resp3 oob push support (#841)Michael Grunder
Proper support for RESP3 PUSH messages. By default, PUSH messages are now intercepted and the reply memory freed. This means existing code should work unchanged when connecting to Redis >= 6.0.0 even if `CLIENT TRACKING` were then enabled. Additionally, we define two callbacks users can configure if they wish to handle these messages in a custom way: void redisPushFn(void *privdata, void *reply); void redisAsyncPushFn(redisAsyncContext *ac, void *reply); See #825
2020-05-30Merge branch 'master' into new-ssl-apimichael-grunder
2020-05-26Document allocator injection and completeness fix in test.c (#824)Michael Grunder
2020-05-25Use unique names for allocator struct members (#823)Michael Grunder
Using `strdup` as a struct member causes issues in older gcc
2020-05-24New SSL API to replace redisSecureConnection().Yossi Gottlieb
2020-05-22Allow users to replace allocator and handle OOM everywhere. (#800)Michael Grunder
* Adds an indirection to every allocation/deallocation to allow users to plug in ones of their choosing (use custom functions, jemalloc, etc). * Gracefully handle OOM everywhere in hiredis. This should make it possible for users of the library to have more flexibility in how they handle such situations. * Changes `redisReaderTask->elements` from an `int` to a `long long` to prevent a possible overflow when transferring the task elements into a `redisReply`. * Adds a configurable `max elements` member to `redisReader` that defaults to 2^32 - 1. This can be set to "unlimited" by setting the value to zero.
2020-05-21Add logic to handle RESP3 push messages (#819)Michael Grunder
Fixes #815
2020-05-19Resp3 verbatim string support (#805)Michael Grunder
Pull RESP3 verbatim string handling from Redis Fixes #802
2020-05-04Remove nested depth limitation. (#797)Michael Grunder
* Remove nested depth limitation. This commit removes the nested multi-bulk depth limitation of 7. We do this by switching to pointer to pointer indirection and growing the stack in chunks when needed. See: #794, #421