From: Vsevolod Stakhov Date: Mon, 11 Jan 2016 16:21:43 +0000 (+0000) Subject: Fix GNU version of strerror_r (hiredis is broken) X-Git-Tag: 1.1.0~64 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=83034f4027106b76d3458d911619d53479c85ea5;p=thirdparty%2Frspamd.git Fix GNU version of strerror_r (hiredis is broken) --- diff --git a/contrib/hiredis/hiredis.h b/contrib/hiredis/hiredis.h index edba658860..62a903c0a3 100644 --- a/contrib/hiredis/hiredis.h +++ b/contrib/hiredis/hiredis.h @@ -37,6 +37,7 @@ #include /* for va_list */ #include /* for struct timeval */ #include /* uintXX_t, etc */ +#include /* strerror_r, etc */ #include "sds.h" /* for sds */ #define HIREDIS_MAJOR 0 @@ -98,7 +99,7 @@ * then GNU strerror_r returned an internal static buffer and we \ * need to copy the result into our private buffer. */ \ if (err_str != (buf)) { \ - buf[(len)] = '\0'; \ + buf[(len)-1] = '\0'; \ strncat((buf), err_str, ((len) - 1)); \ } \ } while (0) diff --git a/contrib/hiredis/net.c b/contrib/hiredis/net.c index 60a2dc7544..e4aa920ad0 100644 --- a/contrib/hiredis/net.c +++ b/contrib/hiredis/net.c @@ -66,11 +66,13 @@ static void redisContextCloseFd(redisContext *c) { static void __redisSetErrorFromErrno(redisContext *c, int type, const char *prefix) { char buf[128] = { 0 }; + char *p; size_t len = 0; if (prefix != NULL) len = snprintf(buf,sizeof(buf),"%s: ",prefix); - __redis_strerror_r(errno, (char *)(buf + len), sizeof(buf) - len); + p = buf + len; + __redis_strerror_r(errno, p, sizeof(buf) - len); __redisSetError(c,type,buf); }