]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Fix GNU version of strerror_r (hiredis is broken)
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 11 Jan 2016 16:21:43 +0000 (16:21 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 11 Jan 2016 16:21:43 +0000 (16:21 +0000)
contrib/hiredis/hiredis.h
contrib/hiredis/net.c

index edba65886082f2303a630e1889c836a622eb5a2f..62a903c0a32feae7c400b56c8921f1ea956b839e 100644 (file)
@@ -37,6 +37,7 @@
 #include <stdarg.h> /* for va_list */
 #include <sys/time.h> /* for struct timeval */
 #include <stdint.h> /* uintXX_t, etc */
+#include <string.h> /* 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)
index 60a2dc75445c73758de82f2be404a1a6deb25608..e4aa920ad0fa9ef4bf33687f5e2557050a67ab93 100644 (file)
@@ -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);
 }