summaryrefslogtreecommitdiff
path: root/read.c
AgeCommit message (Collapse)Author
2024-03-23all: rename redis -> redict symbols and commentsmasterAnna (navi) Figueiredo Gomes
Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
2024-03-22all: use REUSE with LGPL-3.0-or-later and BSD-3-ClauseAnna (navi) Figueiredo Gomes
Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
2024-01-31Fix review commentsgit-hulk
2024-01-31Add support of RESP3 attribute typegit-hulk
Currently, Redis DEBUG PROTOCOL 'attrib' command will return an attribute type, but hiredis doesn't support it yet. So it got the protocol type error: ``` 127.0.0.1:6379> DEBUG PROTOCOL attrib Error: Protocol error, got "|" as reply type byte ``` After apply this PR, it should reply: ``` 127.0.0.1:6379> DEBUG PROTOCOL attrib 1# "key-popularity" 1# 1) "key:123" 2) (integer) 90 ```
2023-04-14Accept -nan per the RESP3 spec recommendation.Michael Grunder
For reference: https://github.com/redis/redis-specifications/blob/master/protocol/RESP3.md
2022-11-14Add support for nan in RESP3 double (#1133)filipe oliveira
2022-04-24Fix warnings on Win64Orgad Shaneh
read.c:399:27: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 399 | obj = (void*)(long)cur->type; | ^
2021-02-25Fix off-by-one error in seekNewlinemichael-grunder
2021-02-25read: Validate line items prior to checking for object creation callbacksAlex Smith
2021-02-25read: Remove obsolete comment on nested multi bulk depth limitationAlex Smith
2021-02-25read: Add support for the RESP3 bignum typeAlex Smith
2021-02-25read: Ensure no invalid '\r' or '\n' in simple status/error stringsAlex 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-25read: Use memchr() in seekNewline() instead of looping over entire stringAlex Smith
2021-02-25read: Add additional RESP3 bool validationAlex Smith
RESP3 bools should be only one of "#t\r\n" or "#f\r\n". We also allow capital 'T' and 'F' to be lenient.
2021-02-25read: Add additional RESP3 nil validationAlex Smith
RESP3 nil should consist of "_\r\n" and nothing else.
2021-02-25read: Fix double validation and infinity parsingAlex Smith
The ',' protocol byte gets removed in processItem(), so it should not be compared against in processLineItem(). strtod() allows multiple representations of infinity and NaN that are not RESP3 compliant. Since we explicitly check for the two compliant infinity cases, strtod() should only return finite values.
2020-07-21Fix a static analysis false positivemichael-grunder
Static analyzer's can't tell that hi_calloc is calloc-like, and report a potential null pointer dereference. This isn't possible but it's probably smarter to make the test anyway in the event code changes.
2020-06-07sdsrange overflow fix (#830)Michael Grunder
Fix overflow bug in `sdsrange`
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
2020-01-01fix spelling mistakesShooterIT
2019-08-28Fix MSVC build.Yossi Gottlieb
2019-08-27Merge pull request #697 from yossigo/resp3Mark Nunberg
Port RESP3 support from Redis.
2019-08-09Merge branch 'master' into createArray-size_tMark Nunberg
2019-08-04RESP3 support changes from Redis.Yossi Gottlieb
This corresponds to commits d5c54f0b..bea09a7f in the redis repository.
2019-08-04Initial RESP3 support [d5c54f0b].Yossi Gottlieb
2019-05-30redisReaderGetReply leak memoryqi.yang
2018-09-24Make string2ll static to avoid conflict with redisTom Lee
See discussion on #609. This should also make it easier for redis to update the vendored/bundled hiredis (though not by much).
2018-05-21Update createArray to take size_tJustin Brewer
This makes createArray consistent with createString, which also takes size_t. Bounds-check and unit tests are updated to allow up to min(SIZE_MAX,LLONG_MAX). Changelog is updated to mention this API break. Signed-off-by: Justin Brewer <jzb0012@auburn.edu>
2018-05-20Use string2ll from Redismichael-grunder
This commit pulls string2ll from Redis (with permission from Antirez) as strtoll is 2-3x slower and even worse vs the original version in hiredis that didn't check for overflow at all. By using string2ll there is almost no measurable performance impact of overflow detection even in integer parsing heavy workloads (e.g. INCRBY commands).
2018-05-20Fix bulk and multi-bulk length truncationJustin Brewer
processMultiBulkItem truncates the value read from readLongLong, resulting in a corrupted state when the next item is read. createArray takes an int, so bound to INT_MAX. Inspection showed that processBulkItem had the same truncation issue. createString takes size_t, so bound to SIZE_MAX. This only has an effect on 32-bit platforms. A strict lower bound is also added, since negative lengths other than -1 are invalid according to RESP. Signed-off-by: Justin Brewer <jzb0012@auburn.edu>
2018-05-19Properly detect integer parse errorsJustin Brewer
Badly formatted or out-of-range integers are now protocol errors. Signed-off-by: Justin Brewer <jzb0012@auburn.edu>
2018-04-30Remove redundant NULL checksJustin Brewer
free(NULL) is a valid NOP. Most of the hiredis free functions behave the same way. redisReaderFree is updated to also be NULL-safe. There is one redundant NULL check at sds.c:1036, but it's left as is since sds is imported from upstream. Signed-off-by: Justin Brewer <jzb0012@auburn.edu>
2018-04-30Remove redundant zero storesJustin Brewer
calloc is guaranteed to provide a zero-initialized buffer. There is no need to set fields to zero explicitly. Signed-off-by: Justin Brewer <jzb0012@auburn.edu>
2018-01-05calloc param fixes and NULL checkcdliuqiang@gmail.com
2016-04-11Update read.cDongwenHuang
static char *seekNewline(char *s, size_t len) : this function can not parse the string,such as "hello world\r". the case that the last char is '\r'.
2015-03-13Added support for compiling the parser code with Microsoft Visual C compiler.tzickel
For hiredis-py and others support on windows.
2015-01-05Refactor reading code into read.ctzickel
Makes hiredis reading functions easier to include in external projects [fixed all merge conflicts against current version] Closes #249