Blame SOURCES/cups-stringpool-setprinterattr.patch

ea9550
diff -up cups-1.6.2/scheduler/printers.c.stringpool-setprinterattr cups-1.6.2/scheduler/printers.c
ea9550
--- cups-1.6.2/scheduler/printers.c.stringpool-setprinterattr	2013-06-13 12:16:07.525680621 +0100
ea9550
+++ cups-1.6.2/scheduler/printers.c	2013-06-13 12:16:07.567680782 +0100
ea9550
@@ -1925,6 +1925,7 @@ cupsdSetPrinterAttr(
ea9550
   ipp_attribute_t	*attr;		/* Attribute */
ea9550
   int			i,		/* Looping var */
ea9550
 			count;		/* Number of values */
ea9550
+  char			*value_dup;	/* Copy of attribute value string */
ea9550
   char			*ptr,		/* Pointer into value */
ea9550
 			*start,		/* Start of value */
ea9550
 			quote;		/* Quote character */
ea9550
@@ -1993,16 +1994,24 @@ cupsdSetPrinterAttr(
ea9550
       return;
ea9550
     }
ea9550
 
ea9550
-    for (i = 0; i < count; i ++)
ea9550
+    if ((value_dup = strdup(value)) == NULL)
ea9550
     {
ea9550
-      if ((ptr = strchr(value, ',')) != NULL)
ea9550
+      cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to copy attribute value.");
ea9550
+      return;
ea9550
+    }
ea9550
+
ea9550
+    for (i = 0, start = value_dup; i < count; i ++)
ea9550
+    {
ea9550
+      if ((ptr = strchr(start, ',')) != NULL)
ea9550
         *ptr++ = '\0';
ea9550
 
ea9550
-      attr->values[i].integer = strtol(value, NULL, 10);
ea9550
+      attr->values[i].integer = strtol(start, NULL, 10);
ea9550
 
ea9550
       if (ptr)
ea9550
-        value = ptr;
ea9550
+        start = ptr;
ea9550
     }
ea9550
+
ea9550
+    free(value_dup);
ea9550
   }
ea9550
   else
ea9550
   {
ea9550
@@ -2043,7 +2052,13 @@ cupsdSetPrinterAttr(
ea9550
       return;
ea9550
     }
ea9550
 
ea9550
-    for (i = 0, quote = '\0', ptr = value; i < count; i ++)
ea9550
+    if ((value_dup = strdup(value)) == NULL)
ea9550
+    {
ea9550
+      cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to copy attribute value.");
ea9550
+      return;
ea9550
+    }
ea9550
+
ea9550
+    for (i = 0, quote = '\0', ptr = value_dup; i < count; i ++)
ea9550
     {
ea9550
       for (start = ptr; *ptr; ptr ++)
ea9550
       {
ea9550
@@ -2071,6 +2086,8 @@ cupsdSetPrinterAttr(
ea9550
 
ea9550
       attr->values[i].string.text = _cupsStrAlloc(start);
ea9550
     }
ea9550
+
ea9550
+    free(value_dup);
ea9550
   }
ea9550
 }
ea9550