[gegl/soc-2011-warp: 19/25] gegl-path: remove dead code and potential security issue in gegl_path_parse_string



commit 5aaa9a54c64ec3505af733fef767bb66b08c0936
Author: Michael Murà <batolettre gmail com>
Date:   Tue Aug 2 13:59:49 2011 +0200

    gegl-path: remove dead code and potential security issue in gegl_path_parse_string

 gegl/property-types/gegl-path.c |  104 ++++++++++++++++-----------------------
 1 files changed, 43 insertions(+), 61 deletions(-)
---
diff --git a/gegl/property-types/gegl-path.c b/gegl/property-types/gegl-path.c
index 184dfaa..0aa1315 100644
--- a/gegl/property-types/gegl-path.c
+++ b/gegl/property-types/gegl-path.c
@@ -791,83 +791,65 @@ gegl_path_parse_string (GeglPath    *vector,
   const gchar *p = path;
   InstructionInfo *previnfo = NULL;
   gdouble x0, y0, x1, y1, x2, y2;
-  gchar *param_name = NULL;
 
   while (*p)
     {
-      gchar     type = *p;
+      gchar            type = *p;
+      InstructionInfo *info = lookup_instruction_info(type);
 
-      if (type == '!')
+      if (!info && ((type>= '0' && type <= '9') || type == '-'))
         {
-          gint i = 0;
-          if (param_name)
-            g_free (param_name);
-          param_name = g_malloc0 (32); /* XXX: nasty limitation, might have
-                                          security issues */
-          p++;
-          while (*p != ' ')
+          if (!previnfo)   /* XXX: suspicious code !!! */
             {
-              param_name[i++]=*p;
-              p++;
+              info = previnfo;
+              type = previnfo->type;  /* XXX: previnfo _is_ NULL */
             }
-        }
-      else
-        {
-          InstructionInfo *info = lookup_instruction_info(type);
-          if (!info && ((type>= '0' && type <= '9') || type == '-'))
+          else
             {
-              if (!previnfo)   /* XXX: suspicious code !!! */
+              if (previnfo->type == 'M')
                 {
-                  info = previnfo;
-                  type = previnfo->type;  /* XXX: previnfo _is_ NULL */
+                  info = lookup_instruction_info(type = 'L');
                 }
-              else
+              else if (previnfo->type == 'm')
                 {
-                  if (previnfo->type == 'M')
-                    {
-                      info = lookup_instruction_info(type = 'L');
-                    }
-                  else if (previnfo->type == 'm')
-                    {
-                      info = lookup_instruction_info(type = 'l');
-                    }
-                  else if (previnfo->type == ' ')
-                    g_warning ("EEEK");
+                  info = lookup_instruction_info(type = 'l');
                 }
+              else if (previnfo->type == ' ')
+                g_warning ("EEEK");
             }
+        }
 
-          if (info)
+      if (info)
+        {
+          switch (info->n_items)
             {
-              switch (info->n_items)
-                {
-                  case 0:
-                    priv->path = gegl_path_list_append (priv->path, type, 0., 0.);
-                    /* coordinates are ignored, all of these could have used add3)*/
-                    break;
-                  case 2:
-                    p = parse_float_pair (p, &x0, &y0);
-                    priv->path = gegl_path_list_append (priv->path, type, x0, y0);
-                    continue;
-                  case 4:
-                    p = parse_float_pair (p, &x0, &y0);
-                    p = parse_float_pair (p, &x1, &y1);
-                    priv->path = gegl_path_list_append (priv->path, type, x0, y0, x1, y1);
-                    continue;
-                  case 6:
-                    p = parse_float_pair (p, &x0, &y0);
-                    p = parse_float_pair (p, &x1, &y1);
-                    p = parse_float_pair (p, &x2, &y2);
-                    priv->path = gegl_path_list_append (priv->path, type, x0, y0, x1, y1, x2, y2);
-                    continue;
-                  default:
-                    g_warning ("parsing of data %i items not implemented\n", info->n_items);
-                    continue;
-                }
-              previnfo = info;
+              case 0:
+                priv->path = gegl_path_list_append (priv->path, type, 0., 0.);
+                /* coordinates are ignored, all of these could have used add3)*/
+                break;
+              case 2:
+                p = parse_float_pair (p, &x0, &y0);
+                priv->path = gegl_path_list_append (priv->path, type, x0, y0);
+                continue;
+              case 4:
+                p = parse_float_pair (p, &x0, &y0);
+                p = parse_float_pair (p, &x1, &y1);
+                priv->path = gegl_path_list_append (priv->path, type, x0, y0, x1, y1);
+                continue;
+              case 6:
+                p = parse_float_pair (p, &x0, &y0);
+                p = parse_float_pair (p, &x1, &y1);
+                p = parse_float_pair (p, &x2, &y2);
+                priv->path = gegl_path_list_append (priv->path, type, x0, y0, x1, y1, x2, y2);
+                continue;
+              default:
+                g_warning ("parsing of data %i items not implemented\n", info->n_items);
+                continue;
             }
-          if (*p)
-            p++;
+          previnfo = info;
         }
+      if (*p)
+        p++;
     }
 
   priv->flat_path_clean = FALSE;
@@ -910,7 +892,7 @@ gegl_path_append (GeglPath *self,
 
   if (type == 'L')
     {
-	  /* special case lineto so that the full path doesn't need
+      /* special case lineto so that the full path doesn't need
          to be re-rendered */
 
       GeglPathList *iter2;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]