naccyde / rpms / systemd

Forked from rpms/systemd a year ago
Clone
8d419f
From c10efc8164dcdf8596315ce98f60405f8c2e17c0 Mon Sep 17 00:00:00 2001
8d419f
From: Yu Watanabe <watanabe.yu+github@gmail.com>
8d419f
Date: Tue, 14 Jun 2022 09:05:00 +0900
8d419f
Subject: [PATCH] locale-util: check if enumerated locales are valid
8d419f
8d419f
(cherry picked from commit a2f7937747f12634d93049f645cdae88f89ff233)
8d419f
8d419f
Related: #2087652
8d419f
---
8d419f
 src/basic/locale-util.c | 9 +++++++++
8d419f
 1 file changed, 9 insertions(+)
8d419f
8d419f
diff --git a/src/basic/locale-util.c b/src/basic/locale-util.c
8d419f
index abbebc7666..bd36cdd1cd 100644
8d419f
--- a/src/basic/locale-util.c
8d419f
+++ b/src/basic/locale-util.c
8d419f
@@ -199,6 +199,15 @@ int get_locales(char ***ret) {
8d419f
         if (r < 0)
8d419f
                 return r;
8d419f
 
8d419f
+        char *locale;
8d419f
+        SET_FOREACH(locale, locales) {
8d419f
+                r = locale_is_installed(locale);
8d419f
+                if (r < 0)
8d419f
+                        return r;
8d419f
+                if (r == 0)
8d419f
+                        free(set_remove(locales, locale));
8d419f
+        }
8d419f
+
8d419f
         l = set_get_strv(locales);
8d419f
         if (!l)
8d419f
                 return -ENOMEM;