]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
intl: Fix tst-gettext under inherited LC_* environment
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Thu, 21 May 2026 13:26:31 +0000 (10:26 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 25 May 2026 13:51:20 +0000 (13:51 +0000)
The final block of tst-gettext unsets LC_ALL plus LC_MESSAGES, LC_CTYPE,
LC_TIME and LC_NUMERIC, sets LANG=existing-locale, and then expects
setlocale (LC_ALL, "") to resolve every category through LANG.  Any
other LC_* category inherited from the invoking shell (e.g. LC_PAPER,
LC_MONETARY) still takes precedence over LANG, and if it points to a
locale that is not under the test's LOCPATH the setlocale call fails
with ENOENT.

Checked on x86_64-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
intl/tst-gettext.c

index 8c60e337f3521310137b6a14b8a6ac6a5f7bb628..d8605b2a05e1f725699a073ecd1933f53418ec0e 100644 (file)
@@ -204,11 +204,22 @@ main (int argc, char *argv[])
       result = 1;
     }
 
-  /* Now the same tests with LANG deciding.  */
+  /* Now the same tests with LANG deciding.  Unset every LC_* category so that
+     values inherited from the invoking shell (e.g. LC_PAPER) cannot leak into
+     setlocale (LC_ALL, "") below and force it to look up a locale that is not
+     under the test's LOCPATH.  */
   unsetenv ("LC_MESSAGES");
   unsetenv ("LC_CTYPE");
   unsetenv ("LC_TIME");
   unsetenv ("LC_NUMERIC");
+  unsetenv ("LC_COLLATE");
+  unsetenv ("LC_MONETARY");
+  unsetenv ("LC_PAPER");
+  unsetenv ("LC_NAME");
+  unsetenv ("LC_ADDRESS");
+  unsetenv ("LC_TELEPHONE");
+  unsetenv ("LC_MEASUREMENT");
+  unsetenv ("LC_IDENTIFICATION");
   setenv ("LANG", "existing-locale", 1);
   check_setlocale (LC_ALL, "");
   /* This is the name of the existing domain with a catalog for the