@@ -62,9 +62,19 @@ __xpg_strerror_r (int errnum, char *buf, size_t buflen)
if (sub >= es->max_sub)
estr = (const char *) es->bad_sub;
else if (code >= es->subsystem[sub].max_code)
- return EINVAL;
+ {
+ __snprintf (buf, buflen, "%s%d", _("Unknown error code: "), code);
+ return EINVAL;
+ }
else
- estr = (const char *) _(es->subsystem[sub].codes[code]);
+ {
+ estr = (const char *) _(es->subsystem[sub].codes[code]);
+ if (estr == NULL)
+ {
+ __snprintf (buf, buflen, "%s%d", _("Unknown error code: "), code);
+ return EINVAL;
+ }
+ }
size_t estrlen = strlen (estr);