Commit Graph

801 Commits

Author SHA1 Message Date
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
Hyungjin Kim
be76c56b51 Consider sub by pattern when clear subscribed flag 2017-01-30 20:00:04 +09:00
Jan-Erik Rediger
c9b72f97f8 Merge pull request #499 from jinq0123/fixbug/redisSetErrorFromErrno
Fix __redisSetErrorFromErrno() can not get error string.
2017-01-23 17:03:14 +01:00
Jin Qing
25cd884f6b Fix __redisSetErrorFromErrno() can not get error string.
snprintf() may change errno.
2016-12-30 23:13:02 +08:00
not-a-robot
33152ad163 Auto merge of #429 - xinchuantao:master, r=badboy
using new version libevent
2016-12-09 11:37:25 +01:00
not-a-robot
b4f9fc1a2a Auto merge of #468 - paul-scott:master, r=badboy
Prevented uv adapter from calling write when context has been freed

The `redisLibuvPoll` function can be called with both the `UV_READABLE` and `UV_WRITABLE` flags set at the same time.  Calling `redisAsyncHandleRead` can lead to a disconnect and the context being cleaned up/freed.  If this happens then `redisAsyncHandleWrite` should not be called otherwise memory read/write errors and duplicate freeing will occur.

These changes prevent this from happening by having the `redisLibuvCleanup` callback indicate that the context has been cleaned.  This is done indirectly by setting the context to a null pointer, maybe someone can come up with a cleaner way.
2016-12-09 11:12:16 +01:00
Jan-Erik Rediger
8636d90821 Avoid unchecked malloc
Closes #471
2016-12-09 10:51:26 +01:00
Jan-Erik Rediger
afdef3e6ec Merge pull request #479 from DonaldWhyte/patch-1
Remove trailing comma in redisConnectionType enum
2016-11-04 15:22:16 +01:00
Donald Whyte
41b07dab5e Remove trailing comma in redisConnectionType enum
Remove trailing comma in last value of `redisConnectionType` enum. This causes a compiler warning on Solaris compilers. I'd like to build this on Solaris with `-Werror`. However, due to the trailing comma, I cannot do that.

This PR removes the trailing comma, which should prevent it causing compiler warnings on any architecture.
2016-10-25 09:25:24 +01:00
Trustfarm-heart
06eedd8a24 Build error patch with glib-2.0
In case of some glib-2.0 linker error ,
make examples 
can't link with glib2.0,  in this case -lglib-2.0  to after includes and move to last will solve the issues.
2016-10-10 04:17:28 +09:00
Hyungjin Kim
073dc84399 Counting pending subscribe. Fix #396 2016-09-30 00:26:32 +09:00
Paul Scott
cbb956567b Prevented uv adapter from calling write when context has been freed 2016-09-19 11:48:54 +10:00