Re: [PATCH] kconfig: protect locale-unsafe calls

From
Arnaud Lacombe <hidden>
Date
2011-08-16 05:21:47
Reply to
Arnaud Lacombe, 2011-08-16
Hi,

On Tue, Aug 16, 2011 at 1:19 AM, Arnaud Lacombe [off-list ref] wrote:
There is a few calls in kconfig where we end-up using tolower(3) or toupper(3)
in an unsafe manner. As highlighted by Serdar, it would seem that Turkish's
locale do not have representable lowercase for the Engligh capital-dotless-i.

Introduces locale-safe portion in the backend where we reset the local to the
default "C".

Reported-by: Serdar KÖYLÜ <redacted>
Signed-off-by: Arnaud Lacombe <redacted>
This is not a perfect solution as we might writing stuff on the
console on those protected range, but that's a start.

 - Arnaud
quoted hunk ↗ jump to hunk
---
 scripts/kconfig/confdata.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 5a58965..7b1bbb8 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -828,6 +828,8 @@ static int conf_split_config(void)
       if (chdir("include/config"))
               return 1;

+       setlocale(LC_ALL, "C");
+
       res = 0;
       for_all_symbols(i, sym) {
               sym_calc_value(sym);
@@ -918,6 +920,9 @@ static int conf_split_config(void)
               }
               close(fd);
       }
+
+       setlocale(LC_ALL, "");
+
 out:
       if (chdir("../.."))
               return 1;
@@ -956,6 +961,8 @@ int conf_write_autoconf(void)
               return 1;
       }

+       setlocale(LC_ALL, "C");
+
       conf_write_heading(out, &kconfig_printer_cb, NULL);

       conf_write_heading(tristate, &tristate_printer_cb, NULL);
@@ -979,6 +986,9 @@ int conf_write_autoconf(void)
               conf_write_symbol(out_h, sym, &header_printer_cb, NULL);
       }
+
+       setlocale(LC_ALL, "");
+
       fclose(out);
       fclose(tristate);
       fclose(out_h);
--
1.7.6.153.g78432
Thread (6 messages) 6 messages, 2 authors, last reply 2011-09-01
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help