Skip to content

Commit

Permalink
pal: Strerror_s(3) cannot return ERANGE in case of the short buffer.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
altimeter-130ft committed Jan 18, 2024
1 parent 0429d82 commit b09f688
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/flb_pal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b09f688

Please sign in to comment.