Skip to content
Snippets Groups Projects
Commit 88177975 authored by Michael Biebl's avatar Michael Biebl
Browse files

Try harder to look up the right localization

Fixes out-of-bounds read in _localize.

Closes: #956223
parent 5ba80a3a
No related branches found
No related tags found
No related merge requests found
From: Matthias Clasen <mclasen@redhat.com>
Date: Wed, 27 Jun 2012 20:28:00 -0400
Subject: Try harder to look up the right localization
The code for looking up localized strings for action descriptions
was manually trying to break locale names into pieces, but didn't
get it right for e.g. zh_CN.utf-8. Instead, use the GLib function
g_get_locale_variants(), which handles this (and more). This fixes
the translation problem reported in
https://bugzilla.gnome.org/show_bug.cgi?id=665497
Signed-off-by: David Zeuthen <zeuthen@gmail.com>
(cherry picked from commit facadfb5c8c52ba45fd20ffe3b6d3ddd4208a427)
---
src/polkitbackend/polkitbackendactionpool.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/src/polkitbackend/polkitbackendactionpool.c b/src/polkitbackend/polkitbackendactionpool.c
index e3ed38d..0af0010 100644
--- a/src/polkitbackend/polkitbackendactionpool.c
+++ b/src/polkitbackend/polkitbackendactionpool.c
@@ -1108,7 +1108,7 @@ _localize (GHashTable *translations,
const gchar *lang)
{
const gchar *result;
- gchar lang2[256];
+ gchar **langs;
guint n;
if (lang == NULL)
@@ -1123,16 +1123,14 @@ _localize (GHashTable *translations,
goto out;
/* we could have a translation for 'da' but lang=='da_DK'; cut off the last part and try again */
- strncpy (lang2, lang, sizeof (lang2));
- for (n = 0; lang2[n] != '\0'; n++)
+ langs = g_get_locale_variants (lang);
+ for (n = 0; langs[n] != NULL; n++)
{
- if (lang2[n] == '_')
- {
- lang2[n] = '\0';
- break;
- }
+ result = (const char *) g_hash_table_lookup (translations, (void *) langs[n]);
+ if (result != NULL)
+ break;
}
- result = (const char *) g_hash_table_lookup (translations, (void *) lang2);
+ g_strfreev (langs);
if (result != NULL)
goto out;
......@@ -20,7 +20,7 @@ Bug-Debian: https://bugs.debian.org/796134
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/src/polkitbackend/polkitbackendactionpool.c b/src/polkitbackend/polkitbackendactionpool.c
index e3ed38d..4270d4e 100644
index 0af0010..b16ed2f 100644
--- a/src/polkitbackend/polkitbackendactionpool.c
+++ b/src/polkitbackend/polkitbackendactionpool.c
@@ -40,7 +40,6 @@
......
......@@ -9,7 +9,7 @@ Bug-Ubuntu: https://launchpad.net/bugs/619632
1 file changed, 49 insertions(+)
diff --git a/src/polkitbackend/polkitbackendactionpool.c b/src/polkitbackend/polkitbackendactionpool.c
index 4270d4e..e2dbf9e 100644
index b16ed2f..3b0e400 100644
--- a/src/polkitbackend/polkitbackendactionpool.c
+++ b/src/polkitbackend/polkitbackendactionpool.c
@@ -24,6 +24,8 @@
......@@ -173,7 +173,7 @@ index 4270d4e..e2dbf9e 100644
const gchar *lang)
{
const gchar *result;
gchar lang2[256];
gchar **langs;
guint n;
+
+ if (domain != NULL)
......
0.106/agenthelper-pam-Fix-newline-trimming-code.patch
0.107/Try-harder-to-look-up-the-right-localization.patch
0.108/build-Fix-.gir-generation-for-parallel-make.patch
0.108/PolkitAgent-Avoid-crashing-if-initializing-the-server-obj.patch
0.110/07_set-XAUTHORITY-environment-variable-if-unset.patch
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment