Skip to content

Commit 109849e

Browse files
committed
Bugfix: strerror_r can return an error, and if it does, POSIX does not specify the content of the buffer
1 parent a60838d commit 109849e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/netbase.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,8 @@ std::string NetworkErrorString(int err)
12651265
#ifdef STRERROR_R_CHAR_P /* GNU variant can return a pointer outside the passed buffer */
12661266
s = strerror_r(err, buf, sizeof(buf));
12671267
#else /* POSIX variant always returns message in buffer */
1268-
(void) strerror_r(err, buf, sizeof(buf));
1268+
if (strerror_r(err, buf, sizeof(buf)))
1269+
buf[0] = 0;
12691270
#endif
12701271
return strprintf("%s (%d)", s, err);
12711272
}

0 commit comments

Comments
 (0)