aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Dashjr <luke-jr+git@utopios.org>2014-07-07 15:34:00 +0000
committerLuke Dashjr <luke-jr+git@utopios.org>2014-07-07 15:34:00 +0000
commit109849e204f91d8b04b0e57da87e45b461096b50 (patch)
treed9773b5d4bc6901b58250bb0b35b58a3a08e1f43
parenta60838d09aed4d976e9343e8329d61afff204435 (diff)
Bugfix: strerror_r can return an error, and if it does, POSIX does not specify the content of the buffer
-rw-r--r--src/netbase.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/netbase.cpp b/src/netbase.cpp
index e24a0a195c..40ae89957a 100644
--- a/src/netbase.cpp
+++ b/src/netbase.cpp
@@ -1265,7 +1265,8 @@ std::string NetworkErrorString(int err)
#ifdef STRERROR_R_CHAR_P /* GNU variant can return a pointer outside the passed buffer */
s = strerror_r(err, buf, sizeof(buf));
#else /* POSIX variant always returns message in buffer */
- (void) strerror_r(err, buf, sizeof(buf));
+ if (strerror_r(err, buf, sizeof(buf)))
+ buf[0] = 0;
#endif
return strprintf("%s (%d)", s, err);
}