|
|
51f0aa |
commit a1a6a401ab0a3c9f15fb7eaebbdcee24192254e8
|
|
|
51f0aa |
Author: Florian Weimer <fweimer@redhat.com>
|
|
|
51f0aa |
Date: Tue Aug 26 19:38:59 2014 +0200
|
|
|
51f0aa |
|
|
|
51f0aa |
__gconv_translit_find: Disable function [BZ #17187]
|
|
|
51f0aa |
|
|
|
51f0aa |
This functionality has never worked correctly, and the implementation
|
|
|
51f0aa |
contained a security vulnerability (CVE-2014-5119).
|
|
|
51f0aa |
|
|
|
ce426f |
2014-08-21 Florian Weimer <fweimer@redhat.com>
|
|
|
ce426f |
|
|
|
ce426f |
[BZ #17187]
|
|
|
ce426f |
* iconv/gconv_trans.c (struct known_trans, search_tree, lock,
|
|
|
ce426f |
trans_compare, open_translit, __gconv_translit_find):
|
|
|
ce426f |
Remove module loading code.
|
|
|
ce426f |
|
|
|
ce426f |
diff --git glibc-2.17-c758a686/iconv/gconv_trans.c glibc-2.17-c758a686/iconv/gconv_trans.c
|
|
|
ce426f |
index 1e25854..d71c029 100644
|
|
|
ce426f |
--- glibc-2.17-c758a686/iconv/gconv_trans.c
|
|
|
ce426f |
+++ glibc-2.17-c758a686/iconv/gconv_trans.c
|
|
|
ce426f |
@@ -238,181 +238,11 @@ __gconv_transliterate (struct __gconv_step *step,
|
|
|
ce426f |
return __GCONV_ILLEGAL_INPUT;
|
|
|
ce426f |
}
|
|
|
ce426f |
|
|
|
ce426f |
-
|
|
|
ce426f |
-/* Structure to represent results of found (or not) transliteration
|
|
|
ce426f |
- modules. */
|
|
|
ce426f |
-struct known_trans
|
|
|
ce426f |
-{
|
|
|
ce426f |
- /* This structure must remain the first member. */
|
|
|
ce426f |
- struct trans_struct info;
|
|
|
ce426f |
-
|
|
|
ce426f |
- char *fname;
|
|
|
ce426f |
- void *handle;
|
|
|
ce426f |
- int open_count;
|
|
|
ce426f |
-};
|
|
|
ce426f |
-
|
|
|
ce426f |
-
|
|
|
ce426f |
-/* Tree with results of previous calls to __gconv_translit_find. */
|
|
|
ce426f |
-static void *search_tree;
|
|
|
ce426f |
-
|
|
|
ce426f |
-/* We modify global data. */
|
|
|
ce426f |
-__libc_lock_define_initialized (static, lock);
|
|
|
ce426f |
-
|
|
|
ce426f |
-
|
|
|
ce426f |
-/* Compare two transliteration entries. */
|
|
|
ce426f |
-static int
|
|
|
ce426f |
-trans_compare (const void *p1, const void *p2)
|
|
|
ce426f |
-{
|
|
|
ce426f |
- const struct known_trans *s1 = (const struct known_trans *) p1;
|
|
|
ce426f |
- const struct known_trans *s2 = (const struct known_trans *) p2;
|
|
|
ce426f |
-
|
|
|
ce426f |
- return strcmp (s1->info.name, s2->info.name);
|
|
|
ce426f |
-}
|
|
|
ce426f |
-
|
|
|
ce426f |
-
|
|
|
ce426f |
-/* Open (maybe reopen) the module named in the struct. Get the function
|
|
|
ce426f |
- and data structure pointers we need. */
|
|
|
ce426f |
-static int
|
|
|
ce426f |
-open_translit (struct known_trans *trans)
|
|
|
ce426f |
-{
|
|
|
ce426f |
- __gconv_trans_query_fct queryfct;
|
|
|
ce426f |
-
|
|
|
ce426f |
- trans->handle = __libc_dlopen (trans->fname);
|
|
|
ce426f |
- if (trans->handle == NULL)
|
|
|
ce426f |
- /* Not available. */
|
|
|
ce426f |
- return 1;
|
|
|
ce426f |
-
|
|
|
ce426f |
- /* Find the required symbol. */
|
|
|
ce426f |
- queryfct = __libc_dlsym (trans->handle, "gconv_trans_context");
|
|
|
ce426f |
- if (queryfct == NULL)
|
|
|
ce426f |
- {
|
|
|
ce426f |
- /* We cannot live with that. */
|
|
|
ce426f |
- close_and_out:
|
|
|
ce426f |
- __libc_dlclose (trans->handle);
|
|
|
ce426f |
- trans->handle = NULL;
|
|
|
ce426f |
- return 1;
|
|
|
ce426f |
- }
|
|
|
ce426f |
-
|
|
|
ce426f |
- /* Get the context. */
|
|
|
ce426f |
- if (queryfct (trans->info.name, &trans->info.csnames, &trans->info.ncsnames)
|
|
|
ce426f |
- != 0)
|
|
|
ce426f |
- goto close_and_out;
|
|
|
ce426f |
-
|
|
|
ce426f |
- /* Of course we also have to have the actual function. */
|
|
|
ce426f |
- trans->info.trans_fct = __libc_dlsym (trans->handle, "gconv_trans");
|
|
|
ce426f |
- if (trans->info.trans_fct == NULL)
|
|
|
ce426f |
- goto close_and_out;
|
|
|
ce426f |
-
|
|
|
ce426f |
- /* Now the optional functions. */
|
|
|
ce426f |
- trans->info.trans_init_fct =
|
|
|
ce426f |
- __libc_dlsym (trans->handle, "gconv_trans_init");
|
|
|
ce426f |
- trans->info.trans_context_fct =
|
|
|
ce426f |
- __libc_dlsym (trans->handle, "gconv_trans_context");
|
|
|
ce426f |
- trans->info.trans_end_fct =
|
|
|
ce426f |
- __libc_dlsym (trans->handle, "gconv_trans_end");
|
|
|
ce426f |
-
|
|
|
ce426f |
- trans->open_count = 1;
|
|
|
ce426f |
-
|
|
|
ce426f |
- return 0;
|
|
|
ce426f |
-}
|
|
|
ce426f |
-
|
|
|
ce426f |
-
|
|
|
ce426f |
int
|
|
|
ce426f |
internal_function
|
|
|
ce426f |
__gconv_translit_find (struct trans_struct *trans)
|
|
|
ce426f |
{
|
|
|
ce426f |
- struct known_trans **found;
|
|
|
ce426f |
- const struct path_elem *runp;
|
|
|
ce426f |
- int res = 1;
|
|
|
ce426f |
-
|
|
|
ce426f |
- /* We have to have a name. */
|
|
|
ce426f |
- assert (trans->name != NULL);
|
|
|
ce426f |
-
|
|
|
ce426f |
- /* Acquire the lock. */
|
|
|
ce426f |
- __libc_lock_lock (lock);
|
|
|
ce426f |
-
|
|
|
ce426f |
- /* See whether we know this module already. */
|
|
|
ce426f |
- found = __tfind (trans, &search_tree, trans_compare);
|
|
|
ce426f |
- if (found != NULL)
|
|
|
ce426f |
- {
|
|
|
ce426f |
- /* Is this module available? */
|
|
|
ce426f |
- if ((*found)->handle != NULL)
|
|
|
ce426f |
- {
|
|
|
ce426f |
- /* Maybe we have to reopen the file. */
|
|
|
ce426f |
- if ((*found)->handle != (void *) -1)
|
|
|
ce426f |
- /* The object is not unloaded. */
|
|
|
ce426f |
- res = 0;
|
|
|
ce426f |
- else if (open_translit (*found) == 0)
|
|
|
ce426f |
- {
|
|
|
ce426f |
- /* Copy the data. */
|
|
|
ce426f |
- *trans = (*found)->info;
|
|
|
ce426f |
- (*found)->open_count++;
|
|
|
ce426f |
- res = 0;
|
|
|
ce426f |
- }
|
|
|
ce426f |
- }
|
|
|
ce426f |
- }
|
|
|
ce426f |
- else
|
|
|
ce426f |
- {
|
|
|
ce426f |
- size_t name_len = strlen (trans->name) + 1;
|
|
|
ce426f |
- int need_so = 0;
|
|
|
ce426f |
- struct known_trans *newp;
|
|
|
ce426f |
-
|
|
|
ce426f |
- /* We have to continue looking for the module. */
|
|
|
ce426f |
- if (__gconv_path_elem == NULL)
|
|
|
ce426f |
- __gconv_get_path ();
|
|
|
ce426f |
-
|
|
|
ce426f |
- /* See whether we have to append .so. */
|
|
|
ce426f |
- if (name_len <= 4 || memcmp (&trans->name[name_len - 4], ".so", 3) != 0)
|
|
|
ce426f |
- need_so = 1;
|
|
|
ce426f |
-
|
|
|
ce426f |
- /* Create a new entry. */
|
|
|
ce426f |
- newp = (struct known_trans *) malloc (sizeof (struct known_trans)
|
|
|
ce426f |
- + (__gconv_max_path_elem_len
|
|
|
ce426f |
- + name_len + 3)
|
|
|
ce426f |
- + name_len);
|
|
|
ce426f |
- if (newp != NULL)
|
|
|
ce426f |
- {
|
|
|
ce426f |
- char *cp;
|
|
|
ce426f |
-
|
|
|
ce426f |
- /* Clear the struct. */
|
|
|
ce426f |
- memset (newp, '\0', sizeof (struct known_trans));
|
|
|
ce426f |
-
|
|
|
ce426f |
- /* Store a copy of the module name. */
|
|
|
ce426f |
- newp->info.name = cp = (char *) (newp + 1);
|
|
|
ce426f |
- cp = __mempcpy (cp, trans->name, name_len);
|
|
|
ce426f |
-
|
|
|
ce426f |
- newp->fname = cp;
|
|
|
ce426f |
-
|
|
|
ce426f |
- /* Search in all the directories. */
|
|
|
ce426f |
- for (runp = __gconv_path_elem; runp->name != NULL; ++runp)
|
|
|
ce426f |
- {
|
|
|
ce426f |
- cp = __mempcpy (__stpcpy ((char *) newp->fname, runp->name),
|
|
|
ce426f |
- trans->name, name_len);
|
|
|
ce426f |
- if (need_so)
|
|
|
ce426f |
- memcpy (cp, ".so", sizeof (".so"));
|
|
|
ce426f |
-
|
|
|
ce426f |
- if (open_translit (newp) == 0)
|
|
|
ce426f |
- {
|
|
|
ce426f |
- /* We found a module. */
|
|
|
ce426f |
- res = 0;
|
|
|
ce426f |
- break;
|
|
|
ce426f |
- }
|
|
|
ce426f |
- }
|
|
|
ce426f |
-
|
|
|
ce426f |
- if (res)
|
|
|
ce426f |
- newp->fname = NULL;
|
|
|
ce426f |
-
|
|
|
ce426f |
- /* In any case we'll add the entry to our search tree. */
|
|
|
ce426f |
- if (__tsearch (newp, &search_tree, trans_compare) == NULL)
|
|
|
ce426f |
- {
|
|
|
ce426f |
- /* Yickes, this should not happen. Unload the object. */
|
|
|
ce426f |
- res = 1;
|
|
|
ce426f |
- /* XXX unload here. */
|
|
|
ce426f |
- }
|
|
|
ce426f |
- }
|
|
|
ce426f |
- }
|
|
|
ce426f |
-
|
|
|
ce426f |
- __libc_lock_unlock (lock);
|
|
|
ce426f |
-
|
|
|
ce426f |
- return res;
|
|
|
ce426f |
+ /* This function always fails. Transliteration module loading is
|
|
|
ce426f |
+ not implemented. */
|
|
|
ce426f |
+ return 1;
|
|
|
ce426f |
}
|
|
|
ce426f |
--
|
|
|
ce426f |
1.9.3
|
|
|
ce426f |
|