diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c index 6c7c6982c8d..7048315a8d7 100644 --- a/lib/libc/stdio/vfprintf.c +++ b/lib/libc/stdio/vfprintf.c @@ -312,6 +312,8 @@ __vfprintf(FILE *fp, locale_t locale, const char *fmt0, va_list ap) int width; /* width from format (%8d), or 0 */ int prec; /* precision from format; <0 for N/A */ int saved_errno; + int error; + char errnomsg[NL_TEXTMAX]; char sign; /* sign prefix (' ', '+', '-', or \0) */ struct grouping_state gs; /* thousands' grouping info */ @@ -829,7 +831,9 @@ reswitch: switch (ch) { break; #endif /* !NO_FLOATING_POINT */ case 'm': - cp = strerror(saved_errno); + error = __strerror_rl(saved_errno, errnomsg, + sizeof(errnomsg), locale); + cp = error == 0 ? errnomsg : ""; size = (prec >= 0) ? strnlen(cp, prec) : strlen(cp); sign = '\0'; break;