Skip to content

Commit 418d4ad

Browse files
committed
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)
2 parents 7d05645 + 109849e commit 418d4ad

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
@@ -1252,7 +1252,8 @@ std::string NetworkErrorString(int err)
12521252
#ifdef STRERROR_R_CHAR_P /* GNU variant can return a pointer outside the passed buffer */
12531253
s = strerror_r(err, buf, sizeof(buf));
12541254
#else /* POSIX variant always returns message in buffer */
1255-
(void) strerror_r(err, buf, sizeof(buf));
1255+
if (strerror_r(err, buf, sizeof(buf)))
1256+
buf[0] = 0;
12561257
#endif
12571258
return strprintf("%s (%d)", s, err);
12581259
}

0 commit comments

Comments
 (0)