| 1 | X-Git-Url: https://sourceware.org/git/gitweb.cgi?p=glibc.git;a=blobdiff_plain;f=iconv%2Fgconv_trans.c;h=e0835fc66684e63964b1376a0c730a70225f63f4;hp=1e25854ccfa84e4f612320f61e6cafa2f955a7d9;hb=a1a6a401ab0a3c9f15fb7eaebbdcee24192254e8;hpb=e4e7cfd287686d26fce2218ed5b2d383db5e338a |
| 2 | |
| 3 | diff --git a/iconv/gconv_trans.c b/iconv/gconv_trans.c |
| 4 | index 1e25854..e0835fc 100644 |
| 5 | --- a/iconv/gconv_trans.c |
| 6 | +++ b/iconv/gconv_trans.c |
| 7 | @@ -238,181 +238,12 @@ __gconv_transliterate (struct __gconv_step *step, |
| 8 | return __GCONV_ILLEGAL_INPUT; |
| 9 | } |
| 10 | |
| 11 | - |
| 12 | -/* Structure to represent results of found (or not) transliteration |
| 13 | - modules. */ |
| 14 | -struct known_trans |
| 15 | -{ |
| 16 | - /* This structure must remain the first member. */ |
| 17 | - struct trans_struct info; |
| 18 | - |
| 19 | - char *fname; |
| 20 | - void *handle; |
| 21 | - int open_count; |
| 22 | -}; |
| 23 | - |
| 24 | - |
| 25 | -/* Tree with results of previous calls to __gconv_translit_find. */ |
| 26 | -static void *search_tree; |
| 27 | - |
| 28 | -/* We modify global data. */ |
| 29 | -__libc_lock_define_initialized (static, lock); |
| 30 | - |
| 31 | - |
| 32 | -/* Compare two transliteration entries. */ |
| 33 | -static int |
| 34 | -trans_compare (const void *p1, const void *p2) |
| 35 | -{ |
| 36 | - const struct known_trans *s1 = (const struct known_trans *) p1; |
| 37 | - const struct known_trans *s2 = (const struct known_trans *) p2; |
| 38 | - |
| 39 | - return strcmp (s1->info.name, s2->info.name); |
| 40 | -} |
| 41 | - |
| 42 | - |
| 43 | -/* Open (maybe reopen) the module named in the struct. Get the function |
| 44 | - and data structure pointers we need. */ |
| 45 | -static int |
| 46 | -open_translit (struct known_trans *trans) |
| 47 | -{ |
| 48 | - __gconv_trans_query_fct queryfct; |
| 49 | - |
| 50 | - trans->handle = __libc_dlopen (trans->fname); |
| 51 | - if (trans->handle == NULL) |
| 52 | - /* Not available. */ |
| 53 | - return 1; |
| 54 | - |
| 55 | - /* Find the required symbol. */ |
| 56 | - queryfct = __libc_dlsym (trans->handle, "gconv_trans_context"); |
| 57 | - if (queryfct == NULL) |
| 58 | - { |
| 59 | - /* We cannot live with that. */ |
| 60 | - close_and_out: |
| 61 | - __libc_dlclose (trans->handle); |
| 62 | - trans->handle = NULL; |
| 63 | - return 1; |
| 64 | - } |
| 65 | - |
| 66 | - /* Get the context. */ |
| 67 | - if (queryfct (trans->info.name, &trans->info.csnames, &trans->info.ncsnames) |
| 68 | - != 0) |
| 69 | - goto close_and_out; |
| 70 | - |
| 71 | - /* Of course we also have to have the actual function. */ |
| 72 | - trans->info.trans_fct = __libc_dlsym (trans->handle, "gconv_trans"); |
| 73 | - if (trans->info.trans_fct == NULL) |
| 74 | - goto close_and_out; |
| 75 | - |
| 76 | - /* Now the optional functions. */ |
| 77 | - trans->info.trans_init_fct = |
| 78 | - __libc_dlsym (trans->handle, "gconv_trans_init"); |
| 79 | - trans->info.trans_context_fct = |
| 80 | - __libc_dlsym (trans->handle, "gconv_trans_context"); |
| 81 | - trans->info.trans_end_fct = |
| 82 | - __libc_dlsym (trans->handle, "gconv_trans_end"); |
| 83 | - |
| 84 | - trans->open_count = 1; |
| 85 | - |
| 86 | - return 0; |
| 87 | -} |
| 88 | - |
| 89 | - |
| 90 | int |
| 91 | internal_function |
| 92 | __gconv_translit_find (struct trans_struct *trans) |
| 93 | { |
| 94 | - struct known_trans **found; |
| 95 | - const struct path_elem *runp; |
| 96 | - int res = 1; |
| 97 | - |
| 98 | - /* We have to have a name. */ |
| 99 | - assert (trans->name != NULL); |
| 100 | - |
| 101 | - /* Acquire the lock. */ |
| 102 | - __libc_lock_lock (lock); |
| 103 | - |
| 104 | - /* See whether we know this module already. */ |
| 105 | - found = __tfind (trans, &search_tree, trans_compare); |
| 106 | - if (found != NULL) |
| 107 | - { |
| 108 | - /* Is this module available? */ |
| 109 | - if ((*found)->handle != NULL) |
| 110 | - { |
| 111 | - /* Maybe we have to reopen the file. */ |
| 112 | - if ((*found)->handle != (void *) -1) |
| 113 | - /* The object is not unloaded. */ |
| 114 | - res = 0; |
| 115 | - else if (open_translit (*found) == 0) |
| 116 | - { |
| 117 | - /* Copy the data. */ |
| 118 | - *trans = (*found)->info; |
| 119 | - (*found)->open_count++; |
| 120 | - res = 0; |
| 121 | - } |
| 122 | - } |
| 123 | - } |
| 124 | - else |
| 125 | - { |
| 126 | - size_t name_len = strlen (trans->name) + 1; |
| 127 | - int need_so = 0; |
| 128 | - struct known_trans *newp; |
| 129 | - |
| 130 | - /* We have to continue looking for the module. */ |
| 131 | - if (__gconv_path_elem == NULL) |
| 132 | - __gconv_get_path (); |
| 133 | - |
| 134 | - /* See whether we have to append .so. */ |
| 135 | - if (name_len <= 4 || memcmp (&trans->name[name_len - 4], ".so", 3) != 0) |
| 136 | - need_so = 1; |
| 137 | - |
| 138 | - /* Create a new entry. */ |
| 139 | - newp = (struct known_trans *) malloc (sizeof (struct known_trans) |
| 140 | - + (__gconv_max_path_elem_len |
| 141 | - + name_len + 3) |
| 142 | - + name_len); |
| 143 | - if (newp != NULL) |
| 144 | - { |
| 145 | - char *cp; |
| 146 | - |
| 147 | - /* Clear the struct. */ |
| 148 | - memset (newp, '\0', sizeof (struct known_trans)); |
| 149 | - |
| 150 | - /* Store a copy of the module name. */ |
| 151 | - newp->info.name = cp = (char *) (newp + 1); |
| 152 | - cp = __mempcpy (cp, trans->name, name_len); |
| 153 | - |
| 154 | - newp->fname = cp; |
| 155 | - |
| 156 | - /* Search in all the directories. */ |
| 157 | - for (runp = __gconv_path_elem; runp->name != NULL; ++runp) |
| 158 | - { |
| 159 | - cp = __mempcpy (__stpcpy ((char *) newp->fname, runp->name), |
| 160 | - trans->name, name_len); |
| 161 | - if (need_so) |
| 162 | - memcpy (cp, ".so", sizeof (".so")); |
| 163 | - |
| 164 | - if (open_translit (newp) == 0) |
| 165 | - { |
| 166 | - /* We found a module. */ |
| 167 | - res = 0; |
| 168 | - break; |
| 169 | - } |
| 170 | - } |
| 171 | - |
| 172 | - if (res) |
| 173 | - newp->fname = NULL; |
| 174 | - |
| 175 | - /* In any case we'll add the entry to our search tree. */ |
| 176 | - if (__tsearch (newp, &search_tree, trans_compare) == NULL) |
| 177 | - { |
| 178 | - /* Yickes, this should not happen. Unload the object. */ |
| 179 | - res = 1; |
| 180 | - /* XXX unload here. */ |
| 181 | - } |
| 182 | - } |
| 183 | - } |
| 184 | - |
| 185 | - __libc_lock_unlock (lock); |
| 186 | - |
| 187 | - return res; |
| 188 | + /* Transliteration module loading has been removed because it never |
| 189 | + worked as intended and suffered from a security vulnerability. |
| 190 | + Consequently, this function always fails. */ |
| 191 | + return 1; |
| 192 | } |