summaryrefslogtreecommitdiff
path: root/net.c
diff options
context:
space:
mode:
authorMatt Stancliff <matt@genges.com>2015-01-05 14:48:40 -0500
committerMatt Stancliff <matt@genges.com>2015-01-05 16:53:23 -0500
commitcc202324064ac36a008b85e3b1946e59d83cb8b4 (patch)
treef1012c7c02f48d69696892df66a2f830f9e6c2ee /net.c
parentba3e74c40888fe773290fda2561fdae5d5bb53c7 (diff)
Fix errno error buffers to not clobber errors
The strerror_r API has two flavors depending on system options. The bad flavor uses a static buffer for returning results, so if you save the pointer from strerror_r, the string you're referencing becomes useless if anybody else calls strerror_r again The good flavor does what you expect: it writes the error to your buffer. This commit uses strerror_r directly if it's a good version or copies the static buffer into our private buffer if it's a bad version. Thanks to gemorin for explaining the problem and drafting a fix. Fixes #239
Diffstat (limited to 'net.c')
-rw-r--r--net.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net.c b/net.c
index 0059066..be7a047 100644
--- a/net.c
+++ b/net.c
@@ -67,7 +67,7 @@ static void __redisSetErrorFromErrno(redisContext *c, int type, const char *pref
if (prefix != NULL)
len = snprintf(buf,sizeof(buf),"%s: ",prefix);
- strerror_r(errno,buf+len,sizeof(buf)-len);
+ __redis_strerror_r(errno, (char *)(buf + len), sizeof(buf) - len);
__redisSetError(c,type,buf);
}