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