]> sourceware.org Git - glibc.git/commitdiff
mach: Fix __xpg_strerror_r on in-range but undefined errors [BZ #32350]
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Sat, 9 Nov 2024 18:54:08 +0000 (19:54 +0100)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Sat, 9 Nov 2024 19:00:40 +0000 (20:00 +0100)
For instance, 1073741906 leads to system 16, subsystem 0 and code 82,
which is in range (max_code is 122), but not defined. Return EINVAL in
that case, like

sysdeps/mach/xpg-strerror.c

index f8c65f8124b42bf111c86df408bddcebdc68b3be..5e0e5a41d7ef3e64c83cf51399eba45999a4bde6 100644 (file)
@@ -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);
 
This page took 0.038832 seconds and 5 git commands to generate.