Commit Graph

10 Commits

Author SHA1 Message Date
Tom Lee
c3188bfb1f Make string2ll static to avoid conflict with redis
See discussion on #609. This should also make it easier for redis to
update the vendored/bundled hiredis (though not by much).
2018-09-24 16:14:08 -07:00
michael-grunder
7bef042c03 Use string2ll from Redis
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-20 10:44:19 -07:00
Justin Brewer
1091975857 Fix bulk and multi-bulk length truncation
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-20 09:07:21 -07:00
Justin Brewer
93421f9d84 Properly detect integer parse errors
Badly formatted or out-of-range integers are now protocol errors.

Signed-off-by: Justin Brewer <jzb0012@auburn.edu>
2018-05-19 10:48:14 -07:00
Justin Brewer
58e6b87f51 Remove redundant NULL checks
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-30 21:45:13 -05:00
Justin Brewer
54acc8f087 Remove redundant zero stores
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-04-30 21:45:13 -05:00
cdliuqiang@gmail.com
9219556386 calloc param fixes and NULL check 2018-01-05 16:19:54 +01:00
DongwenHuang
6bfc580a34 Update read.c
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'.
2016-04-11 23:27:45 +08:00
tzickel
ec229678c2 Added support for compiling the parser code with Microsoft Visual C compiler.
For hiredis-py and others support on windows.
2015-03-13 15:58:23 +02:00
tzickel
ba3e74c408 Refactor reading code into read.c
Makes hiredis reading functions easier to include in external projects

[fixed all merge conflicts against current version]

Closes #249
2015-01-05 16:53:22 -05:00