Commit Graph

812 Commits

Author SHA1 Message Date
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
michael-grunder
dbde4f68cf Merge branch 'master' of github.com:redis/hiredis 2018-05-16 09:57:40 -07:00
michael-grunder
9d3b4ec703 Make sure we've got a path separator before the actual dylib name 2018-05-16 09:08:00 -07:00
michael-grunder
03938d7ad2 Merge remote-tracking branch 'ryandesign/install_name' 2018-05-16 09:01:21 -07:00
Michael Grunder
c5cb456421
Merge pull request #596 from ryandesign/cp-pPR
Use cp -pPR instead of cp -a
2018-05-15 18:16:12 -07:00
Ryan Schmidt
0e9af8acb6
Use cp -pPR instead of cp -a
This should be equivalent but compatible with older versions of cp.
2018-05-14 17:37:14 -05:00
Ryan Schmidt
881fcb776d
Use absolute install_name
Fixes #437.
2018-05-14 14:32:05 -05:00
michael-grunder
7a1acdfeb5 Merge remote-tracking branch 'justinbrewer/hiredis-pr1' into posix-build-fixes 2018-05-13 18:08:57 -07:00
michael-grunder
c1af0e849d Attempted fix for Cygwin to expose getaddrinfo and friends 2018-05-09 21:13:01 -07:00
michael-grunder
fbc4971d7d Merge remote-tracking branch 'hyjin/master' 2018-05-09 16:37:00 -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
Justin Brewer
546d9415e1 Fix a segfault on *BSD
freeaddrinfo is not required by POSIX to be NULL-safe. OpenBSD will
SIGSEGV. NetBSD will assert. FreeBSD up to 11.1 will SIGSEGV, while in
future versions, it will be a silent NOP [1].

Commit d4b715f0aa ("Fix potential race in 'invalid timeout' tests")
added a code path to _redisContextConnectTcp which calls
freeaddrinfo(NULL), triggering the segfault. Put a NULL check around the
call to freeaddrinfo.

[1] - e916723903

Signed-off-by: Justin Brewer <jzb0012@auburn.edu>
2018-04-30 21:45:13 -05:00
Justin Brewer
d1c1b668c1 Drop __redis_strerror_r
Since _GNU_SOURCE is now guaranteed to be unset, it is no longer
necessary to support the GNU-specific version of strerror_r.

Drop __redis_strerror_r from the header, and call strerror_r directly.
This breaks any external users of this macro, but they shouldn't have
been using it in  the first place.

Signed-off-by: Justin Brewer <jzb0012@auburn.edu>
2018-04-30 21:45:13 -05:00
Justin Brewer
49bbaacc79 Strip down fmacros.h
strerror_r and addrinfo require _POSIX_C_SOURCE >= 200112L,  which is
implied by _XOPEN_SOURCE >= 600. With the removal of AF_LOCAL usage,
the only non-standard features being used are the TCP_KEEP* socket
flags. _DARWIN_C_SOURCE is required to expose TCP_KEEPALIVE.

Fall back to using _XOPEN_SOURCE 600 for all platforms, and
additionally define _DARWIN_C_SOURCE for Darwin.

Signed-off-by: Justin Brewer <jzb0012@auburn.edu>
2018-04-28 16:35:40 -05:00
Justin Brewer
bbeab80090 Use AF_UNIX
AF_LOCAL is the old, non-standardized name for AF_UNIX. Just use
AF_UNIX, rather than wrestling with platform specifics of AF_LOCAL
definitions.

Signed-off-by: Justin Brewer <jzb0012@auburn.edu>
2018-04-28 16:35:38 -05:00
charsyam
471557c349 fix common realloc mistake and add null check more 2018-03-17 17:41:43 +09:00
not-a-robot[bot]
3d8709d19d Merge #569
569: Ibm aix fix r=badboy
2018-01-06 12:26:55 +00:00
Jan-Erik Rediger
952a33f298 Make it compile on IBM AIX systems
Closes #422
2018-01-06 13:25:35 +01:00
not-a-robot[bot]
a827f5a898 Merge #568
568: Make XOPEN_SOURCE definition explicit per architecture r=badboy

Fixes #441
2018-01-05 19:15:24 +00:00
Jan-Erik Rediger
94ed2e430b Make XOPEN_SOURCE definition explicit per architecture
Fixes #441
2018-01-05 16:20:34 +01:00
cdliuqiang@gmail.com
9219556386 calloc param fixes and NULL check 2018-01-05 16:19:54 +01:00
Jan-Erik Rediger
43284ee495
Merge pull request #561 from zshipko/master
Fix "make install" on OpenBSD
2018-01-05 15:50:31 +01:00
Jan-Erik Rediger
abc60433e6
Merge pull request #564 from dmvo/master
Remove $(ARCH) expansion from the Makefile
2018-01-05 15:49:51 +01:00
Dmitri Vorobiev
12a9d1a32b Strip compiler options from the CC variable
The Makefile checks validity of the compiler command in the CC
variable by feeding the contents of that variable to the `type'
utility. Some environments include compiler options in the CC
variable such as architecture specific tuning flags. For such
cases it is necessary to first strip everything except the
command itself from the contents of the CC variable prior to
checking the command with the type utility, which is what this
patch is introducing. We use shell parameter expansion mechanism
for this purpose.

Signed-off-by: Dmitri Vorobiev <dmitri.vorobiev@movial.com>
2017-12-28 11:42:45 +02:00
Dmitri Vorobiev
3238cf4fe7 Remove $(ARCH) expansion from the Makefile
Some compilation environments (such as Yocto) define the ARCH
environment variable to indicate the target architecture. For
such enviroments, hiredis build fails, because the expanded
$(ARCH) variable in the Makefile gets erroneously interpreted
as an argument to the `-ggdb' command line option during the
compilation stage or as an input file name during the linking
stage.

This patch removes $(ARCH) expansions from the Makefile. This
doesn't harm cross-compilation, the latter goes fine with the
properly assigned CC environment variable. For native builds,
this patch does not imply any changes.

Signed-off-by: Dmitri Vorobiev <dmitri.vorobiev@movial.com>
2017-12-27 14:46:07 +02:00
Zach Shipko
a2ef2b69bf Fix "make install" on OpenBSD 2017-11-28 17:43:11 -08:00
not-a-robot[bot]
07d414731b Merge #554
554: build: do not assume that INSTALL is cp r=badboy

INSTALL is supposed to be `install` in most of the cases which
doesn't work with directories, but works perfectly with files.

Don't do this assumption.

Reported-by: Jiří Vymazal <jvymazal@redhat.com>
References: https://bugzilla.redhat.com/show_bug.cgi?id=1506251
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-11-07 08:26:51 +00:00
Jan-Erik Rediger
f861d9dc50 chore: Build only branches bors needs 2017-11-07 09:26:02 +01:00
Igor Gnatenko
725a96aaa2 build: do not assume that INSTALL is cp
INSTALL is supposed to be `install` in most of the cases which
doesn't work with directories, but works perfectly with files.

Don't do this assumption.

Reported-by: Jiří Vymazal <jvymazal@redhat.com>
References: https://bugzilla.redhat.com/show_bug.cgi?id=1506251
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-10-30 10:22:05 +01:00
Jan-Erik Rediger
43d92c59f3 Merge pull request #542 from EdwardBetts/spelling
correct spelling mistake
2017-09-01 20:47:20 +02:00
Edward Betts
ea42d7e5f6 correct spelling mistake 2017-09-01 18:44:29 +01:00
not-a-robot[bot]
97d611e9b5 Merge #533
533: Small fixes r=badboy
2017-07-15 14:50:49 +00:00
not-a-robot[bot]
74be165c84 Merge #524 #525
524: Don't pass a negative value to __redisAsyncCommand if redisFormatSdsCommandArgv fails r=badboy



525: Fix compilation on FreeBSD 10.3 with default compiler r=badboy

Given FreeBSD 10.3 with default compiler:

> $ cc -v
> FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
> Target: x86_64-unknown-freebsd10.3

Defining _XOPEN_SOURCE to 600 on the fixed line leads to the following errors:

> cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  net.c
> net.c:435:29: error: use of undeclared identifier 'AF_LOCAL'
>     if (redisCreateSocket(c,AF_LOCAL) < 0)
>                             ^
> net.c:460:21: error: use of undeclared identifier 'AF_LOCAL'
>     sa.sun_family = AF_LOCAL;
>                     ^
> 2 errors generated.
> 

AF_LOCAL is defined in sys/socket.h within ifdef __BSD_VISIBLE.

__BSD_VISIBLE could be defined in sys/cdefs.h, but it is never done if _XOPEN_SOURCE is defined.

So on FreeBSD _XOPEN_SOURCE shouldn't be defined.
2017-07-15 14:17:07 +00:00
not-a-robot[bot]
7d99652241 Merge #523
523: Fix leak if setsockopt fails r=badboy
2017-07-15 14:05:56 +00:00
Jan-Erik Rediger
4d8f3fb207 Merge pull request #532 from amallia/assert-side-effects
Assert statement calls a function which has side effects
2017-06-16 08:42:17 +02:00
amallia
3c32344a41 Small fixes 2017-06-15 20:59:37 +01:00
amallia
b46413647f Assert statement calls a function which has side effects 2017-06-15 20:33:23 +01:00
eldarko
6114da6429 Fix compilation on FreeBSD 10.3 with default compiler 2017-05-17 11:03:24 +03:00
Frederik Deweerdt
706129a161 Don't pass a negative value to __redisAsyncCommand if redisFormatSdsCommandArgv fails 2017-05-15 09:20:03 -07:00
Frederik Deweerdt
e21c9c6729 Fix leak if setsockopt fails 2017-05-15 09:14:12 -07:00
Jan-Erik Rediger
97cd8157f7 Merge pull request #514 from zfzsoft/patch-1
redisLibeventCleanup will be leak
2017-04-07 21:12:58 +02:00
Jan-Erik Rediger
2d37f60860 Merge pull request #516 from redis/changed-cygwin
chore(CI): Skip installing Cygwin
2017-04-07 21:12:33 +02:00
Jan-Erik Rediger
fa4d611708 chore(CI): Skip installing Cygwin 2017-04-07 17:42:43 +02:00
Jan-Erik Rediger
f330459ebf Merge pull request #473 from trustfarm-dev/master
Build error when make examples , patch with glib-2.0 positon move will solve.
2017-04-07 16:50:17 +02:00
zfz
515228e5a1 Update libevent.h
event_del can not free the "e->rev" and "e->wev",that will leak when reconnect the redis
2017-03-28 16:46:55 +08:00
Jan-Erik Rediger
29cb95f4f6 Merge pull request #513 from i110/master
suppress gcc complaint
2017-03-22 17:03:16 +01:00
Ichito Nagata
2ec7740c3a suppress gcc complaint 2017-03-22 17:03:52 +09:00
Hyungjin Kim
d4699989ca Use cached local variable instead using accessor 2017-01-30 20:01:01 +09:00