Blame SOURCES/cups-stringpool-setprinterattr.patch

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