From b09f6885c9851d2715da353331f8e10a4b01f61f Mon Sep 17 00:00:00 2001 From: Seigo Tanimura Date: Fri, 19 Jan 2024 03:22:56 +0900 Subject: [PATCH] pal: Strerror_s(3) cannot return ERANGE in case of the short buffer. Such the condition seems not treated as a runtime constraint violation. The best solution is hence to guarantee that the zero status means that a NUL-terminated string is returned. Signed-off-by: Seigo Tanimura --- src/flb_pal.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/flb_pal.c b/src/flb_pal.c index 35c33e17f68..ba5aa226e4c 100644 --- a/src/flb_pal.c +++ b/src/flb_pal.c @@ -63,12 +63,7 @@ int flb_strerror_r(int errnum, char *buf, size_t buflen) return strerror_r(errnum, buf, buflen); #endif #elif defined(FLB_HAVE_STRERROR_S) - int ret; - - ret = (int) strerror_s(buf, (rsize_t)buflen, (errno_t)errnum); - if (0 != ret) { - ret = ERANGE; - } + return (int) strerror_s(buf, (rsize_t)buflen, (errno_t)errnum); #endif } #endif