From c7233aabe57416e8714d617065c3cc5db426e596 Mon Sep 17 00:00:00 2001 From: msweet Date: Tue, 5 Nov 2013 01:14:53 +0000 Subject: [PATCH] Mirror changes from trunk. git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/branches/branch-1.7@11380 a1ca3aef-8c08-0410-bb20-df032aa958be --- CHANGES.txt | 7 +++- scheduler/job.c | 86 +++++++++++++++++++------------------------- scheduler/printers.c | 85 ++++++++++++++++--------------------------- scheduler/printers.h | 19 +++++----- 4 files changed, 83 insertions(+), 114 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index ff2ea8c5c9..97879109e2 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,9 +1,14 @@ -CHANGES.txt - 1.7.1 - 2013-10-28 +CHANGES.txt - 1.7.1 - 2013-11-04 -------------------------------- CHANGES IN CUPS V1.7.1 - Auto debug logging was broken in 1.7.0 () + - Some gzip'd PPD files could not be used () + - Cleaned up some job logging in the scheduler + () + - ATTR messages could cause string pool memory corruption in the + scheduler () CHANGES IN CUPS V1.7.0 diff --git a/scheduler/job.c b/scheduler/job.c index d62fb2f407..db68096a9d 100644 --- a/scheduler/job.c +++ b/scheduler/job.c @@ -312,8 +312,7 @@ cupsdCheckJobs(void) if (job->kill_time && job->kill_time <= curtime) { - cupsdLogMessage(CUPSD_LOG_ERROR, "[Job %d] Stopping unresponsive job.", - job->id); + cupsdLogJob(job, CUPSD_LOG_ERROR, "Stopping unresponsive job."); stop_job(job, CUPSD_JOB_FORCE); continue; @@ -1640,7 +1639,7 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */ * Load job attributes... */ - cupsdLogMessage(CUPSD_LOG_DEBUG, "[Job %d] Loading attributes...", job->id); + cupsdLogJob(job, CUPSD_LOG_DEBUG, "Loading attributes..."); snprintf(jobfile, sizeof(jobfile), "%s/c%05d", RequestRoot, job->id); if ((fp = cupsdOpenConfFile(jobfile)) == NULL) @@ -1648,9 +1647,8 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */ if (ippReadIO(fp, (ipp_iocb_t)cupsFileRead, 1, NULL, job->attrs) != IPP_DATA) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Unable to read job control file \"%s\".", job->id, - jobfile); + cupsdLogJob(job, CUPSD_LOG_ERROR, + "Unable to read job control file \"%s\".", jobfile); cupsFileClose(fp); goto error; } @@ -1663,18 +1661,16 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */ if (!ippFindAttribute(job->attrs, "time-at-creation", IPP_TAG_INTEGER)) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Missing or bad time-at-creation attribute in " - "control file.", job->id); + cupsdLogJob(job, CUPSD_LOG_ERROR, + "Missing or bad time-at-creation attribute in control file."); goto error; } if ((job->state = ippFindAttribute(job->attrs, "job-state", IPP_TAG_ENUM)) == NULL) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Missing or bad job-state attribute in control " - "file.", job->id); + cupsdLogJob(job, CUPSD_LOG_ERROR, + "Missing or bad job-state attribute in control file."); goto error; } @@ -1714,18 +1710,17 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */ if ((attr = ippFindAttribute(job->attrs, "job-printer-uri", IPP_TAG_URI)) == NULL) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] No job-printer-uri attribute in control file.", - job->id); + cupsdLogJob(job, CUPSD_LOG_ERROR, + "No job-printer-uri attribute in control file."); goto error; } if ((dest = cupsdValidateDest(attr->values[0].string.text, &(job->dtype), &destptr)) == NULL) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Unable to queue job for destination \"%s\".", - job->id, attr->values[0].string.text); + cupsdLogJob(job, CUPSD_LOG_ERROR, + "Unable to queue job for destination \"%s\".", + attr->values[0].string.text); goto error; } @@ -1733,9 +1728,9 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */ } else if ((destptr = cupsdFindDest(job->dest)) == NULL) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Unable to queue job for destination \"%s\".", - job->id, job->dest); + cupsdLogJob(job, CUPSD_LOG_ERROR, + "Unable to queue job for destination \"%s\".", + job->dest); goto error; } @@ -1744,9 +1739,8 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */ { const char *reason; /* job-state-reason keyword */ - cupsdLogMessage(CUPSD_LOG_DEBUG, - "[Job %d] Adding missing job-state-reasons attribute to " - " control file.", job->id); + cupsdLogJob(job, CUPSD_LOG_DEBUG, + "Adding missing job-state-reasons attribute to control file."); switch (job->state_value) { @@ -1811,9 +1805,8 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */ if ((attr = ippFindAttribute(job->attrs, "job-priority", IPP_TAG_INTEGER)) == NULL) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Missing or bad job-priority attribute in " - "control file.", job->id); + cupsdLogJob(job, CUPSD_LOG_ERROR, + "Missing or bad job-priority attribute in control file."); goto error; } @@ -1825,9 +1818,9 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */ if ((attr = ippFindAttribute(job->attrs, "job-originating-user-name", IPP_TAG_NAME)) == NULL) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Missing or bad job-originating-user-name " - "attribute in control file.", job->id); + cupsdLogJob(job, CUPSD_LOG_ERROR, + "Missing or bad job-originating-user-name " + "attribute in control file."); goto error; } @@ -1872,9 +1865,8 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */ if (access(jobfile, 0)) break; - cupsdLogMessage(CUPSD_LOG_DEBUG, - "[Job %d] Auto-typing document file \"%s\"...", job->id, - jobfile); + cupsdLogJob(job, CUPSD_LOG_DEBUG, + "Auto-typing document file \"%s\"...", jobfile); if (fileid > job->num_files) { @@ -1900,9 +1892,8 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */ if (!compressions || !filetypes) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Ran out of memory for job file types.", - job->id); + cupsdLogJob(job, CUPSD_LOG_ERROR, + "Ran out of memory for job file types."); ippDelete(job->attrs); job->attrs = NULL; @@ -2210,8 +2201,7 @@ cupsdSaveJob(cupsd_job_t *job) /* I - Job */ if (ippWriteIO(fp, (ipp_iocb_t)cupsFileWrite, 1, NULL, job->attrs) != IPP_DATA) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Unable to write job control file.", job->id); + cupsdLogJob(job, CUPSD_LOG_ERROR, "Unable to write job control file."); cupsFileClose(fp); return; } @@ -4076,8 +4066,7 @@ load_job_cache(const char *filename) /* I - job.cache filename */ job->status_pipes[0] = -1; job->status_pipes[1] = -1; - cupsdLogMessage(CUPSD_LOG_DEBUG, "[Job %d] Loading from cache...", - job->id); + cupsdLogJob(job, CUPSD_LOG_DEBUG, "Loading from cache..."); } else if (!job) { @@ -4146,8 +4135,7 @@ load_job_cache(const char *filename) /* I - job.cache filename */ job->id); if (access(jobfile, 0)) { - cupsdLogMessage(CUPSD_LOG_INFO, "[Job %d] Data files have gone away.", - job->id); + cupsdLogJob(job, CUPSD_LOG_INFO, "Data files have gone away."); job->num_files = 0; continue; } @@ -4157,9 +4145,9 @@ load_job_cache(const char *filename) /* I - job.cache filename */ if (!job->filetypes || !job->compressions) { - cupsdLogMessage(CUPSD_LOG_EMERG, - "[Job %d] Unable to allocate memory for %d files.", - job->id, job->num_files); + cupsdLogJob(job, CUPSD_LOG_EMERG, + "Unable to allocate memory for %d files.", + job->num_files); break; } } @@ -4197,9 +4185,9 @@ load_job_cache(const char *filename) /* I - job.cache filename */ * If the original MIME type is unknown, auto-type it! */ - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Unknown MIME type %s/%s for file %d.", - job->id, super, type, number + 1); + cupsdLogJob(job, CUPSD_LOG_ERROR, + "Unknown MIME type %s/%s for file %d.", + super, type, number + 1); snprintf(jobfile, sizeof(jobfile), "%s/d%05d-%03d", RequestRoot, job->id, number + 1); @@ -4711,7 +4699,7 @@ unload_job(cupsd_job_t *job) /* I - Job */ if (!job->attrs) return; - cupsdLogMessage(CUPSD_LOG_DEBUG, "[Job %d] Unloading...", job->id); + cupsdLogJob(job, CUPSD_LOG_DEBUG, "Unloading..."); ippDelete(job->attrs); diff --git a/scheduler/printers.c b/scheduler/printers.c index 540b536c5a..ecf2ce1d48 100644 --- a/scheduler/printers.c +++ b/scheduler/printers.c @@ -1,55 +1,16 @@ /* * "$Id$" * - * Printer routines for the CUPS scheduler. + * Printer routines 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/". - * - * 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/". */ /* @@ -1866,12 +1827,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 */ @@ -1887,11 +1849,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 ++) { @@ -1939,15 +1912,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 @@ -1989,7 +1962,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 ++) { @@ -2018,6 +1991,8 @@ cupsdSetPrinterAttr( attr->values[i].string.text = _cupsStrAlloc(start); } } + + free(temp); } diff --git a/scheduler/printers.h b/scheduler/printers.h index a5ced9f21c..fd5e47bd0a 100644 --- a/scheduler/printers.h +++ b/scheduler/printers.h @@ -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); -- 2.47.2