mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-18 16:42:54 +01:00
Bugfix: strerror_r can return an error, and if it does, POSIX does not specify the content of the buffer
This commit is contained in:
@@ -1265,7 +1265,8 @@ std::string NetworkErrorString(int err)
|
|||||||
#ifdef STRERROR_R_CHAR_P /* GNU variant can return a pointer outside the passed buffer */
|
#ifdef STRERROR_R_CHAR_P /* GNU variant can return a pointer outside the passed buffer */
|
||||||
s = strerror_r(err, buf, sizeof(buf));
|
s = strerror_r(err, buf, sizeof(buf));
|
||||||
#else /* POSIX variant always returns message in buffer */
|
#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
|
#endif
|
||||||
return strprintf("%s (%d)", s, err);
|
return strprintf("%s (%d)", s, err);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user