]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
<rdar://problem/15382819> cups.org: String pool corruption bug
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Tue, 5 Nov 2013 01:05:00 +0000 (01:05 +0000)
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Tue, 5 Nov 2013 01:05:00 +0000 (01:05 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@11377 a1ca3aef-8c08-0410-bb20-df032aa958be

CHANGES-1.7.txt
scheduler/printers.c
scheduler/printers.h

index 243436f3917db64e81a728d34240a4de6051cd37..0fdc4c0f1c13b07d022f990fd648169a99a8e15c 100644 (file)
@@ -5,6 +5,10 @@ CHANGES IN CUPS V1.7.1
 
        - Auto debug logging was broken in 1.7.0 (<rdar://problem/15331639>)
        - Some gzip'd PPD files could not be used (<rdar://problem/15386424>)
+       - Cleaned up some job logging in the scheduler
+         (<rdar://problem/15332672>)
+       - ATTR messages could cause string pool memory corruption in the
+         scheduler (<rdar://problem/15382819>)
 
 
 CHANGES IN CUPS V1.7.0
index b4781769ef23699c73b250ea5c3680d307477c2f..e1539406cc2c4d0eceebd5acc8b55aaaf16e760b 100644 (file)
@@ -1,55 +1,16 @@
 /*
  * "$Id$"
  *
- *   Printer routines for the CUPS scheduler.
+ * Printer routines for the CUPS scheduler.
  *
- *   Copyright 2007-2013 by Apple Inc.
- *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2013 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
- *   These coded instructions, statements, and computer programs are the
- *   property of Apple Inc. and are protected by Federal copyright
- *   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
- *   which should have been included with this file.  If this file is
- *   file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- *   cupsdAddPrinter()          - Add a printer to the system.
- *   cupsdCreateCommonData()    - Create the common printer data.
- *   cupsdDeleteAllPrinters()   - Delete all printers from the system.
- *   cupsdDeletePrinter()       - Delete a printer from the system.
- *   cupsdFindDest()            - Find a destination in the list.
- *   cupsdFindPrinter()         - Find a printer in the list.
- *   cupsdLoadAllPrinters()     - Load printers from the printers.conf file.
- *   cupsdRenamePrinter()       - Rename a printer.
- *   cupsdSaveAllPrinters()     - Save all printer definitions to the
- *                                printers.conf file.
- *   cupsdSetAuthInfoRequired() - Set the required authentication info.
- *   cupsdSetDeviceURI()        - Set the device URI for a printer.
- *   cupsdSetPrinterAttr()      - Set a printer attribute.
- *   cupsdSetPrinterAttrs()     - Set printer attributes based upon the PPD
- *                                file.
- *   cupsdSetPrinterReasons()   - Set/update the reasons strings.
- *   cupsdSetPrinterState()     - Update the current state of a printer.
- *   cupsdStopPrinter()         - Stop a printer from printing any jobs...
- *   cupsdUpdatePrinterPPD()    - Update keywords in a printer's PPD file.
- *   cupsdUpdatePrinters()      - Update printers after a partial reload.
- *   cupsdValidateDest()        - Validate a printer/class destination.
- *   cupsdWritePrintcap()       - Write a pseudo-printcap file for older
- *                                applications that need it...
- *   add_printer_defaults()     - Add name-default attributes to the printer
- *                                attributes.
- *   add_printer_filter()       - Add a MIME filter for a printer.
- *   add_printer_formats()      - Add document-format-supported values for a
- *                                printer.
- *   compare_printers()         - Compare two printers.
- *   delete_printer_filters()   - Delete all MIME filters for a printer.
- *   dirty_printer()            - Mark config and state files dirty for the
- *                                specified printer.
- *   load_ppd()                 - Load a cached PPD file, updating the cache as
- *                                needed.
- *   new_media_col()            - Create a media-col collection value.
- *   write_xml_string()         - Write a string with XML escaping.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file.  If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  */
 
 /*
@@ -1870,12 +1831,13 @@ void
 cupsdSetPrinterAttr(
     cupsd_printer_t *p,                        /* I - Printer */
     const char      *name,             /* I - Attribute name */
-    char            *value)            /* I - Attribute value string */
+    const char      *value)            /* I - Attribute value string */
 {
   ipp_attribute_t      *attr;          /* Attribute */
   int                  i,              /* Looping var */
                        count;          /* Number of values */
-  char                 *ptr,           /* Pointer into value */
+  char                 *temp,          /* Temporary copy of value string */
+                       *ptr,           /* Pointer into value */
                        *start,         /* Start of value */
                        quote;          /* Quote character */
   ipp_tag_t            value_tag;      /* Value tag for this attribute */
@@ -1891,11 +1853,22 @@ cupsdSetPrinterAttr(
     return;
   }
 
+ /*
+  * Copy the value string so we can do what we want with it...
+  */
+
+  if ((temp = strdup(value)) == NULL)
+  {
+    cupsdLogMessage(CUPSD_LOG_ERROR,
+                    "Unable to duplicate value for \"%s\" attribute.", name);
+    return;
+  }
+
  /*
   * Count the number of values...
   */
 
-  for (count = 1, quote = '\0', ptr = value;
+  for (count = 1, quote = '\0', ptr = temp;
        *ptr;
        ptr ++)
   {
@@ -1943,15 +1916,15 @@ cupsdSetPrinterAttr(
       return;
     }
 
-    for (i = 0; i < count; i ++)
+    for (i = 0, start = temp; i < count; i ++)
     {
-      if ((ptr = strchr(value, ',')) != NULL)
+      if ((ptr = strchr(start, ',')) != NULL)
         *ptr++ = '\0';
 
-      attr->values[i].integer = strtol(value, NULL, 10);
+      attr->values[i].integer = strtol(start, NULL, 10);
 
       if (ptr)
-        value = ptr;
+        start = ptr;
     }
   }
   else
@@ -1993,7 +1966,7 @@ cupsdSetPrinterAttr(
       return;
     }
 
-    for (i = 0, quote = '\0', ptr = value; i < count; i ++)
+    for (i = 0, quote = '\0', ptr = temp; i < count; i ++)
     {
       for (start = ptr; *ptr; ptr ++)
       {
@@ -2022,6 +1995,8 @@ cupsdSetPrinterAttr(
       attr->values[i].string.text = _cupsStrAlloc(start);
     }
   }
+
+  free(temp);
 }
 
 
index a5ced9f21c5b18c3977ff4492b014ef9dc03e1c2..fd5e47bd0a05d1f8516ea77a1a002d11d3e9dad9 100644 (file)
@@ -1,16 +1,16 @@
 /*
  * "$Id$"
  *
- *   Printer definitions for the CUPS scheduler.
+ * Printer definitions for the CUPS scheduler.
  *
- *   Copyright 2007-2012 by Apple Inc.
- *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2013 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
- *   These coded instructions, statements, and computer programs are the
- *   property of Apple Inc. and are protected by Federal copyright
- *   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
- *   which should have been included with this file.  If this file is
- *   file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file.  If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  */
 
 #ifdef HAVE_DNSSD
@@ -166,7 +166,8 @@ extern int          cupsdSetAuthInfoRequired(cupsd_printer_t *p,
                                                 ipp_attribute_t *attr);
 extern void            cupsdSetDeviceURI(cupsd_printer_t *p, const char *uri);
 extern void            cupsdSetPrinterAttr(cupsd_printer_t *p,
-                                           const char *name, char *value);
+                                           const char *name,
+                                           const char *value);
 extern void            cupsdSetPrinterAttrs(cupsd_printer_t *p);
 extern int             cupsdSetPrinterReasons(cupsd_printer_t *p,
                                               const char *s);