summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorSam Mendoza-Jonas <sam@mendozajonas.com>2016-03-02 15:36:36 +1100
committerSam Mendoza-Jonas <sam@mendozajonas.com>2016-03-15 14:23:13 +1100
commit0a10130b9d66a6f3f94094400871c9410b340674 (patch)
tree38d43060b179cdf0d1fb52a7d4abba437039f2a3 /ui
parentc19daa69bc15e73b7ebf79d5280ba62c86c20b6f (diff)
downloadtalos-petitboot-0a10130b9d66a6f3f94094400871c9410b340674.tar.gz
talos-petitboot-0a10130b9d66a6f3f94094400871c9410b340674.zip
ui/ncurses: Check wcstombs() for error in nc-lang
If we are unable to correctly parse wide-character strings for display in the Language screen (eg. due to an incorrect locale) display an error string instead of continuing to try to display the string. Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/ncurses/nc-lang.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/ui/ncurses/nc-lang.c b/ui/ncurses/nc-lang.c
index 7879c45..a7c9ccc 100644
--- a/ui/ncurses/nc-lang.c
+++ b/ui/ncurses/nc-lang.c
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <string.h>
+#include <locale.h>
#include <talloc/talloc.h>
#include <types/types.h>
@@ -265,8 +266,14 @@ static void lang_screen_setup_widgets(struct lang_screen *screen,
len = wcstombs(NULL, lang->label, 0);
assert(len >= 0);
- label = talloc_array(screen, char, len + 1);
- wcstombs(label, lang->label, len + 1);
+ if (len < 0) {
+ label = talloc_asprintf(screen,
+ "Unable to display text in this locale (%s)\n",
+ setlocale(LC_ALL, NULL));
+ } else {
+ label = talloc_array(screen, char, len + 1);
+ wcstombs(label, lang->label, len + 1);
+ }
selected = config->lang && !strcmp(lang->name, config->lang);
found |= selected;
OpenPOWER on IntegriCloud