[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[f15-branch] Another fix for the loader translations.
- From: Ales Kozumplik <akozumpl redhat com>
- To: anaconda-devel-list redhat com
- Subject: [f15-branch] Another fix for the loader translations.
- Date: Fri, 4 Mar 2011 14:47:18 +0100
Fixes a sigsegv in loadLanguage(). While at it make sure /tmp/translations
is really removed (frees some 700kB of the ramdisk).
Resolves: rhbz#682213
---
loader/lang.c | 25 +++++++++----------------
loader/loadermisc.c | 2 +-
2 files changed, 10 insertions(+), 17 deletions(-)
diff --git a/loader/lang.c b/loader/lang.c
index 94e33e0..7ee7b9c 100644
--- a/loader/lang.c
+++ b/loader/lang.c
@@ -140,7 +140,8 @@ int getLangInfo(struct langInfo ** langs) {
return numLanguages;
}
-void loadLanguage (char * file) {
+void loadLanguage(void)
+{
char *filename;
int fd, hash, rc;
char * key = getenv("LANGKEY");
@@ -149,31 +150,20 @@ void loadLanguage (char * file) {
free(strings), strings = NULL;
numStrings = allocedStrings = 0;
}
-
+
/* english requires no files */
if (!strcmp(key, "en"))
return;
- if (!file) {
- file = filename;
- sprintf(filename, "/etc/loader.tr");
- }
-
- if (access(file, R_OK) == -1) {
- newtWinMessage("Error", "OK", "Translation for %s is not available. "
- "The Installation will proceed in English.", key);
- return ;
- }
+ checked_asprintf(&filename, "/tmp/translation/%s.tr", key);
rc = unpack_archive_file("/etc/loader.tr", "/tmp/translation");
-
if (rc != ARCHIVE_OK || access("/tmp/translation", R_OK) == -1) {
newtWinMessage("Error", "OK", "Cannot get translation file %s.\n",
filename);
return;
}
- checked_asprintf(&filename, "/tmp/translation/%s.tr", key);
fd = open(filename, O_RDONLY);
if (fd < 0) {
newtWinMessage("Error", "OK", "Failed to open /tmp/translation: %m\n");
@@ -198,7 +188,10 @@ void loadLanguage (char * file) {
close(fd);
free(filename);
- unlink("/tmp/translation");
+ int translation_dir_fd = open("/tmp/translation", O_RDONLY);
+ recursiveRemove(translation_dir_fd);
+ close(translation_dir_fd);
+ rmdir("/tmp/translation");
qsort(strings, numStrings, sizeof(*strings), aStringCmp);
}
@@ -220,7 +213,7 @@ static void setLangEnv (int i) {
setenv("LANG", languages[i].lc_all, 1);
setenv("LANGKEY", languages[i].key, 1);
setenv("LINGUAS", languages[i].lang, 1);
- loadLanguage (NULL);
+ loadLanguage();
}
/* choice is the index of the chosen language in languages */
diff --git a/loader/loadermisc.c b/loader/loadermisc.c
index d0ff3d4..61e77bf 100644
--- a/loader/loadermisc.c
+++ b/loader/loadermisc.c
@@ -93,7 +93,7 @@ int copyFile(char * source, char * dest) {
* Do "rm -rf" on the target directory.
*
* Returns 0 on success, nonzero otherwise (i.e. directory doesn't exist or
- * some of its contents couldn't be removed.
+ * some of its contents couldn't be removed).
*
* This is copied from the util-linux-ng project.
*/
--
1.7.3.3
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]