diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-07-08 13:03:25 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-07-08 13:35:56 +0200 |
commit | 418d4ad110965b1830b094dc88993966f901d2e6 (patch) | |
tree | 69e0e269d4e0a442d37c74377105a4286c5769e9 /src/netbase.cpp | |
parent | 7d0564569385439e7d649f92eb02102e5b56a12b (diff) | |
parent | 109849e204f91d8b04b0e57da87e45b461096b50 (diff) |
Merge pull request #4479
109849e Bugfix: strerror_r can return an error, and if it does, POSIX does not specify the content of the buffer (Luke Dashjr)
Diffstat (limited to 'src/netbase.cpp')
-rw-r--r-- | src/netbase.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/netbase.cpp b/src/netbase.cpp index 175406322a..067cfa024b 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -1252,7 +1252,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); } |