obuspa: Return the error when XSI-compliant strerror_r() fails

This commit is contained in:
Michael Polyntsov 2023-11-21 15:24:37 +00:00 committed by Vivek Kumar Dutta
parent cf8c202d01
commit 083ffd8a3f

View file

@ -0,0 +1,15 @@
diff --git a/src/core/usp_err.c b/src/core/usp_err.c
index 1626e58..6db1d42 100755
--- a/src/core/usp_err.c
+++ b/src/core/usp_err.c
@@ -189,7 +189,9 @@ char *USP_ERR_ToString(int err, char *buf, int len)
{
#if HAVE_STRERROR_R && !STRERROR_R_CHAR_P
// XSI version of strerror_r
- strerror_r(err, buf, len);
+ if (strerror_r(err, buf, len) != 0) {
+ snprintf(buf, len, "Unknown error %d", err);
+ }
return buf;
#else
// GNU version of strerror_r