arrfab / rpms / glibc

Forked from rpms/glibc 4 years ago
Clone

Blame SOURCES/glibc-rh1133812-1.patch

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