Merge pull request #597 from justinbrewer/createArray-size_t
Update createArray to take size_t
This commit is contained in:
commit
3af99d5fd5
15
CHANGELOG.md
15
CHANGELOG.md
@ -12,6 +12,16 @@
|
|||||||
compare to other values, casting might be necessary or can be removed, if
|
compare to other values, casting might be necessary or can be removed, if
|
||||||
casting was applied before.
|
casting was applied before.
|
||||||
|
|
||||||
|
### 0.x.x (unreleased)
|
||||||
|
**BREAKING CHANGES**:
|
||||||
|
|
||||||
|
* Change `redisReply.len` to `size_t`, as it denotes the the size of a string
|
||||||
|
|
||||||
|
User code should compare this to `size_t` values as well.
|
||||||
|
If it was used to compare to other values, casting might be necessary or can be removed, if casting was applied before.
|
||||||
|
|
||||||
|
* `redisReplyObjectFunctions.createArray` now takes `size_t` for its length parameter.
|
||||||
|
|
||||||
### 0.14.0 (2018-09-25)
|
### 0.14.0 (2018-09-25)
|
||||||
|
|
||||||
* Make string2ll static to fix conflict with Redis (Tom Lee [c3188b])
|
* Make string2ll static to fix conflict with Redis (Tom Lee [c3188b])
|
||||||
@ -50,8 +60,9 @@
|
|||||||
* Import latest upstream sds. This breaks applications that are linked against the old hiredis v0.13
|
* Import latest upstream sds. This breaks applications that are linked against the old hiredis v0.13
|
||||||
* Fix warnings, when compiled with -Wshadow
|
* Fix warnings, when compiled with -Wshadow
|
||||||
* Make hiredis compile in Cygwin on Windows, now CI-tested
|
* Make hiredis compile in Cygwin on Windows, now CI-tested
|
||||||
|
* Bulk and multi-bulk lengths less than -1 or greater than `LLONG_MAX` are now
|
||||||
**BREAKING CHANGES**:
|
protocol errors. This is consistent with the RESP specification. On 32-bit
|
||||||
|
platforms, the upper bound is lowered to `SIZE_MAX`.
|
||||||
|
|
||||||
* Remove backwards compatibility macro's
|
* Remove backwards compatibility macro's
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
|
|
||||||
static redisReply *createReplyObject(int type);
|
static redisReply *createReplyObject(int type);
|
||||||
static void *createStringObject(const redisReadTask *task, char *str, size_t len);
|
static void *createStringObject(const redisReadTask *task, char *str, size_t len);
|
||||||
static void *createArrayObject(const redisReadTask *task, int elements);
|
static void *createArrayObject(const redisReadTask *task, size_t elements);
|
||||||
static void *createIntegerObject(const redisReadTask *task, long long value);
|
static void *createIntegerObject(const redisReadTask *task, long long value);
|
||||||
static void *createNilObject(const redisReadTask *task);
|
static void *createNilObject(const redisReadTask *task);
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ static void *createStringObject(const redisReadTask *task, char *str, size_t len
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *createArrayObject(const redisReadTask *task, int elements) {
|
static void *createArrayObject(const redisReadTask *task, size_t elements) {
|
||||||
redisReply *r, *parent;
|
redisReply *r, *parent;
|
||||||
|
|
||||||
r = createReplyObject(REDIS_REPLY_ARRAY);
|
r = createReplyObject(REDIS_REPLY_ARRAY);
|
||||||
|
2
read.c
2
read.c
@ -385,7 +385,7 @@ static int processMultiBulkItem(redisReader *r) {
|
|||||||
|
|
||||||
root = (r->ridx == 0);
|
root = (r->ridx == 0);
|
||||||
|
|
||||||
if (elements < -1 || elements > INT_MAX) {
|
if (elements < -1 || (LLONG_MAX > SIZE_MAX && elements > SIZE_MAX)) {
|
||||||
__redisReaderSetError(r,REDIS_ERR_PROTOCOL,
|
__redisReaderSetError(r,REDIS_ERR_PROTOCOL,
|
||||||
"Multi-bulk length out of range");
|
"Multi-bulk length out of range");
|
||||||
return REDIS_ERR;
|
return REDIS_ERR;
|
||||||
|
2
read.h
2
read.h
@ -72,7 +72,7 @@ typedef struct redisReadTask {
|
|||||||
|
|
||||||
typedef struct redisReplyObjectFunctions {
|
typedef struct redisReplyObjectFunctions {
|
||||||
void *(*createString)(const redisReadTask*, char*, size_t);
|
void *(*createString)(const redisReadTask*, char*, size_t);
|
||||||
void *(*createArray)(const redisReadTask*, int);
|
void *(*createArray)(const redisReadTask*, size_t);
|
||||||
void *(*createInteger)(const redisReadTask*, long long);
|
void *(*createInteger)(const redisReadTask*, long long);
|
||||||
void *(*createNil)(const redisReadTask*);
|
void *(*createNil)(const redisReadTask*);
|
||||||
void (*freeObject)(void*);
|
void (*freeObject)(void*);
|
||||||
|
4
test.c
4
test.c
@ -360,7 +360,8 @@ static void test_reply_reader(void) {
|
|||||||
freeReplyObject(reply);
|
freeReplyObject(reply);
|
||||||
redisReaderFree(reader);
|
redisReaderFree(reader);
|
||||||
|
|
||||||
test("Set error when array > INT_MAX: ");
|
#if LLONG_MAX > SIZE_MAX
|
||||||
|
test("Set error when array > SIZE_MAX: ");
|
||||||
reader = redisReaderCreate();
|
reader = redisReaderCreate();
|
||||||
redisReaderFeed(reader, "*9223372036854775807\r\n+asdf\r\n",29);
|
redisReaderFeed(reader, "*9223372036854775807\r\n+asdf\r\n",29);
|
||||||
ret = redisReaderGetReply(reader,&reply);
|
ret = redisReaderGetReply(reader,&reply);
|
||||||
@ -369,7 +370,6 @@ static void test_reply_reader(void) {
|
|||||||
freeReplyObject(reply);
|
freeReplyObject(reply);
|
||||||
redisReaderFree(reader);
|
redisReaderFree(reader);
|
||||||
|
|
||||||
#if LLONG_MAX > SIZE_MAX
|
|
||||||
test("Set error when bulk > SIZE_MAX: ");
|
test("Set error when bulk > SIZE_MAX: ");
|
||||||
reader = redisReaderCreate();
|
reader = redisReaderCreate();
|
||||||
redisReaderFeed(reader, "$9223372036854775807\r\nasdf\r\n",28);
|
redisReaderFeed(reader, "$9223372036854775807\r\nasdf\r\n",28);
|
||||||
|
Loading…
Reference in New Issue
Block a user