about summary refs log tree commit diff
path: root/iconv
diff options
context:
space:
mode:
Diffstat (limited to 'iconv')
-rw-r--r--iconv/Versions3
-rw-r--r--iconv/gconv.h48
-rw-r--r--iconv/gconv_close.c14
-rw-r--r--iconv/gconv_int.h30
-rw-r--r--iconv/gconv_open.c152
-rw-r--r--iconv/gconv_trans.c12
-rw-r--r--iconv/loop.c14
-rw-r--r--iconv/skeleton.c14
8 files changed, 32 insertions, 255 deletions
diff --git a/iconv/Versions b/iconv/Versions
index 5d50cf11e2..60ab10a277 100644
--- a/iconv/Versions
+++ b/iconv/Versions
@@ -6,5 +6,8 @@ libc {
   GLIBC_PRIVATE {
     # functions shared with iconv program
     __gconv_get_alias_db; __gconv_get_cache; __gconv_get_modules_db;
+
+    # function used by the gconv modules
+    __gconv_transliterate;
   }
 }
diff --git a/iconv/gconv.h b/iconv/gconv.h
index 108dccbb46..7d59bb06c7 100644
--- a/iconv/gconv.h
+++ b/iconv/gconv.h
@@ -56,7 +56,8 @@ enum
 {
   __GCONV_IS_LAST = 0x0001,
   __GCONV_IGNORE_ERRORS = 0x0002,
-  __GCONV_SWAP = 0x0004
+  __GCONV_SWAP = 0x0004,
+  __GCONV_TRANSLIT = 0x0008
 };
 
 
@@ -64,7 +65,6 @@ enum
 struct __gconv_step;
 struct __gconv_step_data;
 struct __gconv_loaded_object;
-struct __gconv_trans_data;
 
 
 /* Type of a conversion function.  */
@@ -80,38 +80,6 @@ typedef int (*__gconv_init_fct) (struct __gconv_step *);
 typedef void (*__gconv_end_fct) (struct __gconv_step *);
 
 
-/* Type of a transliteration/transscription function.  */
-typedef int (*__gconv_trans_fct) (struct __gconv_step *,
-				  struct __gconv_step_data *, void *,
-				  const unsigned char *,
-				  const unsigned char **,
-				  const unsigned char *, unsigned char **,
-				  size_t *);
-
-/* Function to call to provide transliteration module with context.  */
-typedef int (*__gconv_trans_context_fct) (void *, const unsigned char *,
-					  const unsigned char *,
-					  unsigned char *, unsigned char *);
-
-/* Function to query module about supported encoded character sets.  */
-typedef int (*__gconv_trans_query_fct) (const char *, const char ***,
-					size_t *);
-
-/* Constructor and destructor for local data for transliteration.  */
-typedef int (*__gconv_trans_init_fct) (void **, const char *);
-typedef void (*__gconv_trans_end_fct) (void *);
-
-struct __gconv_trans_data
-{
-  /* Transliteration/Transscription function.  */
-  __gconv_trans_fct __trans_fct;
-  __gconv_trans_context_fct __trans_context_fct;
-  __gconv_trans_end_fct __trans_end_fct;
-  void *__data;
-  struct __gconv_trans_data *__next;
-};
-
-
 /* Description of a conversion step.  */
 struct __gconv_step
 {
@@ -163,9 +131,6 @@ struct __gconv_step_data
   __mbstate_t *__statep;
   __mbstate_t __state;	/* This element must not be used directly by
 			   any module; always use STATEP!  */
-
-  /* Transliteration information.  */
-  struct __gconv_trans_data *__trans;
 };
 
 
@@ -177,4 +142,13 @@ typedef struct __gconv_info
   __extension__ struct __gconv_step_data __data __flexarr;
 } *__gconv_t;
 
+/* Transliteration using the locale's data.  */
+extern int __gconv_transliterate (struct __gconv_step *step,
+				  struct __gconv_step_data *step_data,
+				  const unsigned char *inbufstart,
+				  const unsigned char **inbufp,
+				  const unsigned char *inbufend,
+				  unsigned char **outbufstart,
+				  size_t *irreversible);
+
 #endif /* gconv.h */
diff --git a/iconv/gconv_close.c b/iconv/gconv_close.c
index 81f0e0b319..f6394af6ca 100644
--- a/iconv/gconv_close.c
+++ b/iconv/gconv_close.c
@@ -37,20 +37,6 @@ __gconv_close (__gconv_t cd)
   drunp = cd->__data;
   do
     {
-      struct __gconv_trans_data *transp;
-
-      transp = drunp->__trans;
-      while (transp != NULL)
-	{
-	  struct __gconv_trans_data *curp = transp;
-	  transp = transp->__next;
-
-	  if (__glibc_unlikely (curp->__trans_end_fct != NULL))
-	    curp->__trans_end_fct (curp->__data);
-
-	  free (curp);
-	}
-
       if (!(drunp->__flags & __GCONV_IS_LAST) && drunp->__outbuf != NULL)
 	free (drunp->__outbuf);
     }
diff --git a/iconv/gconv_int.h b/iconv/gconv_int.h
index ace076b88f..13b0e99915 100644
--- a/iconv/gconv_int.h
+++ b/iconv/gconv_int.h
@@ -92,21 +92,6 @@ struct gconv_module
 };
 
 
-/* Internal data structure to represent transliteration module.  */
-struct trans_struct
-{
-  const char *name;
-  struct trans_struct *next;
-
-  const char **csnames;
-  size_t ncsnames;
-  __gconv_trans_fct trans_fct;
-  __gconv_trans_context_fct trans_context_fct;
-  __gconv_trans_init_fct trans_init_fct;
-  __gconv_trans_end_fct trans_end_fct;
-};
-
-
 /* Flags for `gconv_open'.  */
 enum
 {
@@ -258,20 +243,7 @@ extern void __gconv_get_builtin_trans (const char *name,
 				       struct __gconv_step *step)
      internal_function;
 
-/* Try to load transliteration step module.  */
-extern int __gconv_translit_find (struct trans_struct *trans)
-     internal_function;
-
-/* Transliteration using the locale's data.  */
-extern int __gconv_transliterate (struct __gconv_step *step,
-				  struct __gconv_step_data *step_data,
-				  void *trans_data,
-				  const unsigned char *inbufstart,
-				  const unsigned char **inbufp,
-				  const unsigned char *inbufend,
-				  unsigned char **outbufstart,
-				  size_t *irreversible) attribute_hidden;
-
+libc_hidden_proto (__gconv_transliterate)
 
 /* If NAME is an codeset alias expand it.  */
 extern int __gconv_compare_alias (const char *name1, const char *name2)
diff --git a/iconv/gconv_open.c b/iconv/gconv_open.c
index bfbe22bff6..615f33dfd2 100644
--- a/iconv/gconv_open.c
+++ b/iconv/gconv_open.c
@@ -39,7 +39,7 @@ __gconv_open (const char *toset, const char *fromset, __gconv_t *handle,
   int conv_flags = 0;
   const char *errhand;
   const char *ignore;
-  struct trans_struct *trans = NULL;
+  bool translit = false;
 
   /* Find out whether any error handling method is specified.  */
   errhand = strchr (toset, '/');
@@ -66,72 +66,10 @@ __gconv_open (const char *toset, const char *fromset, __gconv_t *handle,
 	  while (tok != NULL)
 	    {
 	      if (__strcasecmp_l (tok, "TRANSLIT", _nl_C_locobj_ptr) == 0)
-		{
-		  /* It's the builtin transliteration handling.  We only
-		     support it for working on the internal encoding.  */
-		  static const char *const internal_trans_names[1]
-		    = { "INTERNAL" };
-		  struct trans_struct *lastp = NULL;
-		  struct trans_struct *runp;
-
-		  for (runp = trans; runp != NULL; runp = runp->next)
-		    if (runp->trans_fct == __gconv_transliterate)
-		      break;
-		    else
-		      lastp = runp;
-
-		  if (runp == NULL)
-		    {
-		      struct trans_struct *newp;
-
-		      newp = (struct trans_struct *) alloca (sizeof (*newp));
-		      memset (newp, '\0', sizeof (*newp));
-
-		      /* We leave the `name' field zero to signal that
-			 this is an internal transliteration step.  */
-		      newp->csnames = (const char **) internal_trans_names;
-		      newp->ncsnames = 1;
-		      newp->trans_fct = __gconv_transliterate;
-
-		      if (lastp == NULL)
-			trans = newp;
-		      else
-			lastp->next = newp;
-		    }
-		}
+		translit = true;
 	      else if (__strcasecmp_l (tok, "IGNORE", _nl_C_locobj_ptr) == 0)
 		/* Set the flag to ignore all errors.  */
 		conv_flags |= __GCONV_IGNORE_ERRORS;
-	      else
-		{
-		  /* `tok' is possibly a module name.  We'll see later
-		     whether we can find it.  But first see that we do
-		     not already a module of this name.  */
-		  struct trans_struct *lastp = NULL;
-		  struct trans_struct *runp;
-
-		  for (runp = trans; runp != NULL; runp = runp->next)
-		    if (runp->name != NULL
-			&& __strcasecmp_l (tok, runp->name,
-					   _nl_C_locobj_ptr) == 0)
-		      break;
-		    else
-		      lastp = runp;
-
-		  if (runp == NULL)
-		    {
-		      struct trans_struct *newp;
-
-		      newp = (struct trans_struct *) alloca (sizeof (*newp));
-		      memset (newp, '\0', sizeof (*newp));
-		      newp->name = tok;
-
-		      if (lastp == NULL)
-			trans = newp;
-		      else
-			lastp->next = newp;
-		    }
-		}
 
 	      tok = __strtok_r (NULL, ",", &ptr);
 	    }
@@ -172,25 +110,6 @@ __gconv_open (const char *toset, const char *fromset, __gconv_t *handle,
   res = __gconv_find_transform (toset, fromset, &steps, &nsteps, flags);
   if (res == __GCONV_OK)
     {
-      /* Find the modules.  */
-      struct trans_struct *lastp = NULL;
-      struct trans_struct *runp;
-
-      for (runp = trans; runp != NULL; runp = runp->next)
-	{
-	  if (runp->name == NULL
-	      || __builtin_expect (__gconv_translit_find (runp), 0) == 0)
-	    lastp = runp;
-	  else
-	    {
-	      /* This means we haven't found the module.  Remove it.  */
-	      if (lastp == NULL)
-		trans  = runp->next;
-	      else
-		lastp->next  = runp->next;
-	    }
-	}
-
       /* Allocate room for handle.  */
       result = (__gconv_t) malloc (sizeof (struct __gconv_info)
 				   + (nsteps
@@ -199,8 +118,6 @@ __gconv_open (const char *toset, const char *fromset, __gconv_t *handle,
 	res = __GCONV_NOMEM;
       else
 	{
-	  size_t n;
-
 	  /* Remember the list of steps.  */
 	  result->__steps = steps;
 	  result->__nsteps = nsteps;
@@ -228,47 +145,12 @@ __gconv_open (const char *toset, const char *fromset, __gconv_t *handle,
 	      /* We use the `mbstate_t' member in DATA.  */
 	      result->__data[cnt].__statep = &result->__data[cnt].__state;
 
-	      /* Now see whether we can use any of the transliteration
-		 modules for this step.  */
-	      for (runp = trans; runp != NULL; runp = runp->next)
-		for (n = 0; n < runp->ncsnames; ++n)
-		  if (__strcasecmp_l (steps[cnt].__from_name,
-				      runp->csnames[n], _nl_C_locobj_ptr) == 0)
-		    {
-		      void *data = NULL;
-
-		      /* Match!  Now try the initializer.  */
-		      if (runp->trans_init_fct == NULL
-			  || (runp->trans_init_fct (&data,
-						    steps[cnt].__to_name)
-			      == __GCONV_OK))
-			{
-			  /* Append at the end of the list.  */
-			  struct __gconv_trans_data *newp;
-			  struct __gconv_trans_data **lastp;
-
-			  newp = (struct __gconv_trans_data *)
-			    malloc (sizeof (struct __gconv_trans_data));
-			  if (newp == NULL)
-			    {
-			      res = __GCONV_NOMEM;
-			      goto bail;
-			    }
-
-			  newp->__trans_fct = runp->trans_fct;
-			  newp->__trans_context_fct = runp->trans_context_fct;
-			  newp->__trans_end_fct = runp->trans_end_fct;
-			  newp->__data = data;
-			  newp->__next = NULL;
-
-			  lastp = &result->__data[cnt].__trans;
-			  while (*lastp != NULL)
-			    lastp = &(*lastp)->__next;
-
-			  *lastp = newp;
-			}
-		      break;
-		    }
+	      /* The builtin transliteration handling only
+		 supports the internal encoding.  */
+	      if (translit
+		  && __strcasecmp_l (steps[cnt].__from_name,
+				     "INTERNAL", _nl_C_locobj_ptr) == 0)
+		conv_flags |= __GCONV_TRANSLIT;
 
 	      /* If this is the last step we must not allocate an
 		 output buffer.  */
@@ -309,23 +191,7 @@ __gconv_open (const char *toset, const char *fromset, __gconv_t *handle,
 	  if (result != NULL)
 	    {
 	      while (cnt-- > 0)
-		{
-		  struct __gconv_trans_data *transp;
-
-		  transp = result->__data[cnt].__trans;
-		  while (transp != NULL)
-		    {
-		      struct __gconv_trans_data *curp = transp;
-		      transp = transp->__next;
-
-		      if (__glibc_unlikely (curp->__trans_end_fct != NULL))
-			curp->__trans_end_fct (curp->__data);
-
-		      free (curp);
-		    }
-
-		  free (result->__data[cnt].__outbuf);
-		}
+		free (result->__data[cnt].__outbuf);
 
 	      free (result);
 	      result = NULL;
diff --git a/iconv/gconv_trans.c b/iconv/gconv_trans.c
index e0835fc666..65b5539307 100644
--- a/iconv/gconv_trans.c
+++ b/iconv/gconv_trans.c
@@ -32,7 +32,6 @@
 int
 __gconv_transliterate (struct __gconv_step *step,
 		       struct __gconv_step_data *step_data,
-		       void *trans_data __attribute__ ((unused)),
 		       const unsigned char *inbufstart,
 		       const unsigned char **inbufp,
 		       const unsigned char *inbufend,
@@ -237,13 +236,4 @@ __gconv_transliterate (struct __gconv_step *step,
   /* Haven't found a match.  */
   return __GCONV_ILLEGAL_INPUT;
 }
-
-int
-internal_function
-__gconv_translit_find (struct trans_struct *trans)
-{
-  /* Transliteration module loading has been removed because it never
-     worked as intended and suffered from a security vulnerability.
-     Consequently, this function always fails.  */
-  return 1;
-}
+libc_hidden_def (__gconv_transliterate)
diff --git a/iconv/loop.c b/iconv/loop.c
index a480c0cd40..f4430ed968 100644
--- a/iconv/loop.c
+++ b/iconv/loop.c
@@ -213,8 +213,6 @@
    points.  */
 #define STANDARD_TO_LOOP_ERR_HANDLER(Incr) \
   {									      \
-    struct __gconv_trans_data *trans;					      \
-									      \
     result = __GCONV_ILLEGAL_INPUT;					      \
 									      \
     if (irreversible == NULL)						      \
@@ -227,14 +225,10 @@
     UPDATE_PARAMS;							      \
 									      \
     /* First try the transliteration methods.  */			      \
-    for (trans = step_data->__trans; trans != NULL; trans = trans->__next)    \
-      {									      \
-	result = DL_CALL_FCT (trans->__trans_fct,			      \
-			      (step, step_data, trans->__data, *inptrp,	      \
-			       &inptr, inend, &outptr, irreversible));	      \
-	if (result != __GCONV_ILLEGAL_INPUT)				      \
-	  break;							      \
-      }									      \
+    if ((step_data->__flags & __GCONV_TRANSLIT) != 0)			      \
+      result = __gconv_transliterate					      \
+	(step, step_data, *inptrp,					      \
+	 &inptr, inend, &outptr, irreversible);			      \
 									      \
     REINIT_PARAMS;							      \
 									      \
diff --git a/iconv/skeleton.c b/iconv/skeleton.c
index 73dc1860a9..acd60e2f88 100644
--- a/iconv/skeleton.c
+++ b/iconv/skeleton.c
@@ -501,8 +501,9 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data,
     }
   else
     {
-      /* We preserve the initial values of the pointer variables.  */
-      const unsigned char *inptr = *inptrp;
+      /* We preserve the initial values of the pointer variables,
+	 but only some conversion modules need it.  */
+      const unsigned char *inptr __attribute__ ((__unused__)) = *inptrp;
       unsigned char *outbuf = (__builtin_expect (outbufstart == NULL, 1)
 			       ? data->__outbuf : *outbufstart);
       unsigned char *outend = data->__outbufend;
@@ -592,8 +593,6 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data,
 
       while (1)
 	{
-	  struct __gconv_trans_data *trans;
-
 	  /* Remember the start value for this round.  */
 	  inptr = *inptrp;
 	  /* The outbuf buffer is empty.  */
@@ -640,13 +639,6 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data,
 	      return status;
 	    }
 
-	  /* Give the transliteration module the chance to store the
-	     original text and the result in case it needs a context.  */
-	  for (trans = data->__trans; trans != NULL; trans = trans->__next)
-	    if (trans->__trans_context_fct != NULL)
-	      DL_CALL_FCT (trans->__trans_context_fct,
-			   (trans->__data, inptr, *inptrp, outstart, outbuf));
-
 	  /* We finished one use of the loops.  */
 	  ++data->__invocation_counter;