Skip to content

Commit

Permalink
Bugfix: strerror_r can return an error, and if it does, POSIX does no…
Browse files Browse the repository at this point in the history
…t specify the content of the buffer
  • Loading branch information
luke-jr committed Jul 7, 2014
1 parent a60838d commit 109849e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/netbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 109849e

Please sign in to comment.