diff options
author | msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2012-10-01 03:01:10 +0000 |
---|---|---|
committer | msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2012-10-01 03:01:10 +0000 |
commit | 5a9febac19255ab8aea598449ea63bda730b2fe0 (patch) | |
tree | 1ca7eead0982e5b8893cadd8b2215d1ea96171f7 /cups | |
parent | 37e7e6e0b27c7db3be8e160e87a63fec66e0fcca (diff) |
Merge changes from CUPS 1.7svn-r10629.
git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@3933 a1ca3aef-8c08-0410-bb20-df032aa958be
Diffstat (limited to 'cups')
-rw-r--r-- | cups/Makefile | 4 | ||||
-rw-r--r-- | cups/adminutil.c | 4 | ||||
-rw-r--r-- | cups/adminutil.h | 13 | ||||
-rw-r--r-- | cups/array-private.h | 9 | ||||
-rw-r--r-- | cups/array.c | 35 | ||||
-rw-r--r-- | cups/auth.c | 9 | ||||
-rw-r--r-- | cups/backend.c | 2 | ||||
-rw-r--r-- | cups/conflicts.c | 2 | ||||
-rw-r--r-- | cups/cups-private.h | 1 | ||||
-rw-r--r-- | cups/debug.c | 36 | ||||
-rw-r--r-- | cups/dest-options.c | 34 | ||||
-rw-r--r-- | cups/dest.c | 21 | ||||
-rw-r--r-- | cups/encode.c | 22 | ||||
-rw-r--r-- | cups/globals.c | 2 | ||||
-rw-r--r-- | cups/http-support.c | 12 | ||||
-rw-r--r-- | cups/http.c | 16 | ||||
-rw-r--r-- | cups/ipp.c | 104 | ||||
-rw-r--r-- | cups/ipp.h | 10 | ||||
-rw-r--r-- | cups/langprintf.c | 4 | ||||
-rw-r--r-- | cups/language.c | 22 | ||||
-rw-r--r-- | cups/ppd-cache.c | 296 | ||||
-rw-r--r-- | cups/ppd-private.h | 8 | ||||
-rw-r--r-- | cups/ppd.c | 8 | ||||
-rw-r--r-- | cups/pwg-media.c | 2 | ||||
-rw-r--r-- | cups/request.c | 52 | ||||
-rw-r--r-- | cups/snprintf.c | 36 | ||||
-rw-r--r-- | cups/string.c | 18 | ||||
-rw-r--r-- | cups/testarray.c | 6 | ||||
-rw-r--r-- | cups/testhttp.c | 4 | ||||
-rw-r--r-- | cups/testi18n.c | 14 | ||||
-rw-r--r-- | cups/testppd.c | 14 | ||||
-rw-r--r-- | cups/usersys.c | 6 | ||||
-rw-r--r-- | cups/util.c | 4 |
33 files changed, 526 insertions, 304 deletions
diff --git a/cups/Makefile b/cups/Makefile index 0b6765794..8d5cefd8b 100644 --- a/cups/Makefile +++ b/cups/Makefile @@ -518,7 +518,7 @@ apihelp: --css ../doc/cups-printable.css \ --header api-cups.header --intro api-cups.shtml \ api-cups.xml \ - cups.h adminutil.c dest.c language.c notify.c \ + cups.h adminutil.c dest*.c language.c notify.c \ options.c tempfile.c usersys.c \ util.c >../doc/help/api-cups.html mxmldoc --tokens help/api-cups.html api-cups.xml >../doc/help/api-cups.tokens @@ -573,7 +573,7 @@ framedhelp: --section "Programming" --title "CUPS API" \ --css ../doc/cups-printable.css \ --header api-cups.header --intro api-cups.shtml \ - cups.h adminutil.c dest.c language.c notify.c \ + cups.h adminutil.c dest*.c language.c notify.c \ options.c tempfile.c usersys.c \ util.c mxmldoc --framed api-filedir \ diff --git a/cups/adminutil.c b/cups/adminutil.c index 803d2203c..440e443b5 100644 --- a/cups/adminutil.c +++ b/cups/adminutil.c @@ -65,7 +65,7 @@ static void write_option(cups_file_t *dstfp, int order, /* * 'cupsAdminCreateWindowsPPD()' - Create the Windows PPD file for a printer. * - * @since CUPS 1.2/OS X 10.5@ + * @deprecated@ */ char * /* O - PPD file or NULL */ @@ -393,7 +393,7 @@ cupsAdminCreateWindowsPPD( /* * 'cupsAdminExportSamba()' - Export a printer to Samba. * - * @since CUPS 1.2/OS X 10.5@ + * @deprecated@ */ int /* O - 1 on success, 0 on failure */ diff --git a/cups/adminutil.h b/cups/adminutil.h index 14c681b16..826061570 100644 --- a/cups/adminutil.h +++ b/cups/adminutil.h @@ -3,7 +3,7 @@ * * Administration utility API definitions for CUPS. * - * Copyright 2007-2011 by Apple Inc. + * Copyright 2007-2012 by Apple Inc. * Copyright 2001-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -55,16 +55,19 @@ extern int cupsAdminExportSamba(const char *dest, const char *ppd, const char *samba_server, const char *samba_user, const char *samba_password, - FILE *logfile) _CUPS_API_1_2; + FILE *logfile) _CUPS_DEPRECATED; extern char *cupsAdminCreateWindowsPPD(http_t *http, const char *dest, - char *buffer, int bufsize) _CUPS_API_1_2; + char *buffer, int bufsize) + _CUPS_DEPRECATED; extern int cupsAdminGetServerSettings(http_t *http, int *num_settings, - cups_option_t **settings) _CUPS_API_1_3; + cups_option_t **settings) + _CUPS_API_1_3; extern int cupsAdminSetServerSettings(http_t *http, int num_settings, - cups_option_t *settings) _CUPS_API_1_3; + cups_option_t *settings) + _CUPS_API_1_3; # ifdef __cplusplus diff --git a/cups/array-private.h b/cups/array-private.h index c0d9a92e8..4d3c29734 100644 --- a/cups/array-private.h +++ b/cups/array-private.h @@ -3,7 +3,7 @@ * * Private array definitions for CUPS. * - * Copyright 2011 by Apple Inc. + * Copyright 2011-2012 by Apple Inc. * * These coded instructions, statements, and computer programs are the * property of Apple Inc. and are protected by Federal copyright @@ -37,9 +37,10 @@ extern "C" { * Functions... */ -extern int _cupsArrayAddStrings(cups_array_t *a, const char *s) - _CUPS_API_1_5; -extern cups_array_t *_cupsArrayNewStrings(const char *s) _CUPS_API_1_5; +extern int _cupsArrayAddStrings(cups_array_t *a, const char *s, + char delim) _CUPS_API_1_5; +extern cups_array_t *_cupsArrayNewStrings(const char *s, char delim) + _CUPS_API_1_5; # ifdef __cplusplus } diff --git a/cups/array.c b/cups/array.c index 2fb7701c0..a84f3e2a2 100644 --- a/cups/array.c +++ b/cups/array.c @@ -138,8 +138,7 @@ cupsArrayAdd(cups_array_t *a, /* I - Array */ /* - * '_cupsArrayAddStrings()' - Add zero or more comma-delimited strings to an - * array. + * '_cupsArrayAddStrings()' - Add zero or more delimited strings to an array. * * Note: The array MUST be created using the @link _cupsArrayNewStrings@ * function. Duplicate strings are NOT added. If the string pointer "s" is NULL @@ -148,7 +147,8 @@ cupsArrayAdd(cups_array_t *a, /* I - Array */ int /* O - 1 on success, 0 on failure */ _cupsArrayAddStrings(cups_array_t *a, /* I - Array */ - const char *s) /* I - Comma-delimited strings or NULL */ + const char *s, /* I - Delimited strings or NULL */ + char delim)/* I - Delimiter character */ { char *buffer, /* Copy of string */ *start, /* Start of string */ @@ -159,10 +159,21 @@ _cupsArrayAddStrings(cups_array_t *a, /* I - Array */ if (!a || !s || !*s) return (0); - if (!strchr(s, ',')) + if (delim == ' ') { /* - * String doesn't contain a comma, so add it as a single value... + * Skip leading whitespace... + */ + + while (*s && isspace(*s & 255)) + s ++; + } + + if (!strchr(s, delim) || + (delim == ' ' && !strchr(s, '\t') && !strchr(s, '\n'))) + { + /* + * String doesn't contain a delimiter, so add it as a single value... */ if (!cupsArrayFind(a, (void *)s)) @@ -179,7 +190,14 @@ _cupsArrayAddStrings(cups_array_t *a, /* I - Array */ * it... */ - if ((end = strchr(start, ',')) != NULL) + if (delim == ' ') + { + while (*end && !isspace(*end & 255)) + end ++; + while (*end && isspace(*end & 255)) + *end++ = '\0'; + } + else if ((end = strchr(start, delim)) != NULL) *end++ = '\0'; else end = start + strlen(start); @@ -782,7 +800,8 @@ cupsArrayNew3(cups_array_func_t f, /* I - Comparison function or @code NULL@ fo */ cups_array_t * /* O - Array */ -_cupsArrayNewStrings(const char *s) /* I - Comma-delimited strings or NULL */ +_cupsArrayNewStrings(const char *s, /* I - Delimited strings or NULL */ + char delim) /* I - Delimiter character */ { cups_array_t *a; /* Array */ @@ -790,7 +809,7 @@ _cupsArrayNewStrings(const char *s) /* I - Comma-delimited strings or NULL */ if ((a = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, (cups_acopy_func_t)_cupsStrAlloc, (cups_afree_func_t)_cupsStrFree)) != NULL) - _cupsArrayAddStrings(a, s); + _cupsArrayAddStrings(a, s, delim); return (a); } diff --git a/cups/auth.c b/cups/auth.c index 4b0856ade..fab0db347 100644 --- a/cups/auth.c +++ b/cups/auth.c @@ -190,11 +190,18 @@ cupsDoAuthentication( * Nope - get a new password from the user... */ + char default_username[HTTP_MAX_VALUE]; + /* Default username */ + cg = _cupsGlobals(); if (!cg->lang_default) cg->lang_default = cupsLangDefault(); + if (httpGetSubField(http, HTTP_FIELD_WWW_AUTHENTICATE, "username", + default_username)) + cupsSetUser(default_username); + snprintf(prompt, sizeof(prompt), _cupsLangString(cg->lang_default, _("Password for %s on %s? ")), cupsUser(), @@ -458,7 +465,7 @@ _cupsSetNegotiateAuthString( authsize = sizeof(http->_authstring); } - strcpy(http->authstring, "Negotiate "); + strlcpy(http->authstring, "Negotiate ", authsize); httpEncode64_2(http->authstring + 10, authsize - 10, output_token.value, output_token.length); diff --git a/cups/backend.c b/cups/backend.c index bed23f464..6f8a6b2e8 100644 --- a/cups/backend.c +++ b/cups/backend.c @@ -136,7 +136,7 @@ quote_string(const char *s) /* I - String to write */ if (*s == '\\' || *s == '\"') putchar('\\'); - if (*s == '\n') + if (((*s & 255) < ' ' && *s != '\t') || *s == 0x7f) putchar(' '); else putchar(*s); diff --git a/cups/conflicts.c b/cups/conflicts.c index 456f69053..ae048d135 100644 --- a/cups/conflicts.c +++ b/cups/conflicts.c @@ -930,7 +930,7 @@ ppd_load_constraints(ppd_file_t *ppd) /* I - PPD file */ if (!_cups_strncasecmp(option, "Custom", 6) && !_cups_strcasecmp(choice, "True")) { _cups_strcpy(option, option + 6); - strcpy(choice, "Custom"); + strlcpy(choice, "Custom", sizeof(choice)); } constptr->option = ppdFindOption(ppd, option); diff --git a/cups/cups-private.h b/cups/cups-private.h index 816e72552..4918755bf 100644 --- a/cups/cups-private.h +++ b/cups/cups-private.h @@ -24,6 +24,7 @@ # include "string-private.h" # include "debug-private.h" +# include "array-private.h" # include "ipp-private.h" # include "http-private.h" # include "language-private.h" diff --git a/cups/debug.c b/cups/debug.c index e8298ad06..71b693c70 100644 --- a/cups/debug.c +++ b/cups/debug.c @@ -229,16 +229,8 @@ debug_vsnprintf(char *buffer, /* O - Output buffer */ if (bufptr) { - if ((bufptr + strlen(temp)) > bufend) - { - strncpy(bufptr, temp, (size_t)(bufend - bufptr)); - bufptr = bufend; - } - else - { - strcpy(bufptr, temp); - bufptr += strlen(temp); - } + strlcpy(bufptr, temp, (size_t)(bufend - bufptr)); + bufptr += strlen(bufptr); } break; @@ -267,16 +259,8 @@ debug_vsnprintf(char *buffer, /* O - Output buffer */ if (bufptr) { - if ((bufptr + strlen(temp)) > bufend) - { - strncpy(bufptr, temp, (size_t)(bufend - bufptr)); - bufptr = bufend; - } - else - { - strcpy(bufptr, temp); - bufptr += strlen(temp); - } + strlcpy(bufptr, temp, (size_t)(bufend - bufptr)); + bufptr += strlen(bufptr); } break; @@ -290,16 +274,8 @@ debug_vsnprintf(char *buffer, /* O - Output buffer */ if (bufptr) { - if ((bufptr + strlen(temp)) > bufend) - { - strncpy(bufptr, temp, (size_t)(bufend - bufptr)); - bufptr = bufend; - } - else - { - strcpy(bufptr, temp); - bufptr += strlen(temp); - } + strlcpy(bufptr, temp, (size_t)(bufend - bufptr)); + bufptr += strlen(bufptr); } break; diff --git a/cups/dest-options.c b/cups/dest-options.c index 32616a683..d8eff72e5 100644 --- a/cups/dest-options.c +++ b/cups/dest-options.c @@ -269,13 +269,13 @@ cupsCheckDestSupported( * Returns 1 if there is a conflict, 0 if there are no conflicts, and -1 if * there was an unrecoverable error such as a resolver loop. * - * If "num_conflicts" and "conflicts" are not NULL, they are set to contain the - * list of conflicting option/value pairs. Similarly, if "num_resolved" and - * "resolved" are not NULL they will be set to the list of changes needed to - * resolve the conflict. + * If "num_conflicts" and "conflicts" are not @code NULL@, they are set to + * contain the list of conflicting option/value pairs. Similarly, if + * "num_resolved" and "resolved" are not @code NULL@ they will be set to the + * list of changes needed to resolve the conflict. * * If cupsCopyDestConflicts returns 1 but "num_resolved" and "resolved" are set - * to 0 and NULL, respectively, then the conflict cannot be resolved. + * to 0 and @code NULL@, respectively, then the conflict cannot be resolved. * * @since CUPS 1.6/OS X 10.8@ */ @@ -716,14 +716,13 @@ cupsFreeDestInfo(cups_dinfo_t *dinfo) /* I - Destination information */ /* * 'cupsGetDestMediaByName()' - Get media names, dimensions, and margins. * - * The "media" string is a PWG media name, while "width" and "length" are the - * dimensions in hundredths of millimeters. "flags" provides some matching + * The "media" string is a PWG media name. "Flags" provides some matching * guidance (multiple flags can be combined): * - * CUPS_MEDIA_FLAGS_DEFAULT = find the closest size supported by the printer - * CUPS_MEDIA_FLAGS_BORDERLESS = find a borderless size - * CUPS_MEDIA_FLAGS_DUPLEX = find a size compatible with 2-sided printing - * CUPS_MEDIA_FLAGS_EXACT = find an exact match for the size + * CUPS_MEDIA_FLAGS_DEFAULT = find the closest size supported by the printer, + * CUPS_MEDIA_FLAGS_BORDERLESS = find a borderless size, + * CUPS_MEDIA_FLAGS_DUPLEX = find a size compatible with 2-sided printing, + * CUPS_MEDIA_FLAGS_EXACT = find an exact match for the size, and * CUPS_MEDIA_FLAGS_READY = if the printer supports media sensing, find the * size amongst the "ready" media. * @@ -782,14 +781,13 @@ cupsGetDestMediaByName( /* * 'cupsGetDestMediaBySize()' - Get media names, dimensions, and margins. * - * The "media" string is a PWG media name, while "width" and "length" are the - * dimensions in hundredths of millimeters. "flags" provides some matching - * guidance (multiple flags can be combined): + * "Width" and "length" are the dimensions in hundredths of millimeters. + * "Flags" provides some matching guidance (multiple flags can be combined): * - * CUPS_MEDIA_FLAGS_DEFAULT = find the closest size supported by the printer - * CUPS_MEDIA_FLAGS_BORDERLESS = find a borderless size - * CUPS_MEDIA_FLAGS_DUPLEX = find a size compatible with 2-sided printing - * CUPS_MEDIA_FLAGS_EXACT = find an exact match for the size + * CUPS_MEDIA_FLAGS_DEFAULT = find the closest size supported by the printer, + * CUPS_MEDIA_FLAGS_BORDERLESS = find a borderless size, + * CUPS_MEDIA_FLAGS_DUPLEX = find a size compatible with 2-sided printing, + * CUPS_MEDIA_FLAGS_EXACT = find an exact match for the size, and * CUPS_MEDIA_FLAGS_READY = if the printer supports media sensing, find the * size amongst the "ready" media. * diff --git a/cups/dest.c b/cups/dest.c index 0714f6670..46bc3adb1 100644 --- a/cups/dest.c +++ b/cups/dest.c @@ -319,7 +319,8 @@ cupsAddDest(const char *name, /* I - Destination name */ if (instance && !cupsGetDest(name, NULL, num_dests, *dests)) return (num_dests); - dest = cups_add_dest(name, instance, &num_dests, dests); + if ((dest = cups_add_dest(name, instance, &num_dests, dests)) == NULL) + return (num_dests); /* * Find the base dest again now the array has been realloc'd. @@ -1409,6 +1410,7 @@ _cupsGetDests(http_t *http, /* I - Connection to server or "printer-is-shared", "printer-location", "printer-make-and-model", + "printer-mandatory-job-attributes", "printer-name", "printer-state", "printer-state-change-time", @@ -1514,6 +1516,7 @@ _cupsGetDests(http_t *http, /* I - Connection to server or !strcmp(attr->name, "printer-info") || !strcmp(attr->name, "printer-is-shared") || !strcmp(attr->name, "printer-make-and-model") || + !strcmp(attr->name, "printer-mandatory-job-attributes") || !strcmp(attr->name, "printer-state") || !strcmp(attr->name, "printer-state-change-time") || !strcmp(attr->name, "printer-type") || @@ -1788,7 +1791,7 @@ cupsGetDests2(http_t *http, /* I - Connection to server or @code CUPS_HTTP_ * need to set a default if one exists... */ - if (dest == NULL && defprinter != NULL) + if (!dest && *dests && defprinter) { for (i = 0; i < num_dests; i ++) (*dests)[i].is_default = 0; @@ -2449,7 +2452,7 @@ appleCopyNetwork(void) * 'appleGetPaperSize()' - Get the default paper size. */ -char * /* O - Default paper size */ +static char * /* O - Default paper size */ appleGetPaperSize(char *name, /* I - Paper size name buffer */ int namesize) /* I - Size of buffer */ { @@ -3150,7 +3153,7 @@ cups_dnssd_query_cb( device->state = _CUPS_DNSSD_PENDING; make_and_model[0] = '\0'; - strcpy(model, "Unknown"); + strlcpy(model, "Unknown", sizeof(model)); for (txt = rdata, txtend = txt + rdlen; txt < txtend; @@ -3192,10 +3195,10 @@ cups_dnssd_query_cb( if (!_cups_strcasecmp(key, "usb_MFG") || !_cups_strcasecmp(key, "usb_MANU") || !_cups_strcasecmp(key, "usb_MANUFACTURER")) - strcpy(make_and_model, value); + strlcpy(make_and_model, value, sizeof(make_and_model)); else if (!_cups_strcasecmp(key, "usb_MDL") || !_cups_strcasecmp(key, "usb_MODEL")) - strcpy(model, value); + strlcpy(model, value, sizeof(model)); else if (!_cups_strcasecmp(key, "product") && !strstr(value, "Ghostscript")) { if (value[0] == '(') @@ -3207,14 +3210,14 @@ cups_dnssd_query_cb( if ((ptr = value + strlen(value) - 1) > value && *ptr == ')') *ptr = '\0'; - strcpy(model, value + 1); + strlcpy(model, value + 1, sizeof(model)); } else - strcpy(model, value); + strlcpy(model, value, sizeof(model)); } else if (!_cups_strcasecmp(key, "ty")) { - strcpy(model, value); + strlcpy(model, value, sizeof(model)); if ((ptr = strchr(model, ',')) != NULL) *ptr = '\0'; diff --git a/cups/encode.c b/cups/encode.c index b417fe164..565a43705 100644 --- a/cups/encode.c +++ b/cups/encode.c @@ -39,6 +39,7 @@ static const _ipp_option_t ipp_options[] = { { 1, "auth-info", IPP_TAG_TEXT, IPP_TAG_JOB }, + { 1, "auth-info-default", IPP_TAG_TEXT, IPP_TAG_PRINTER }, { 1, "auth-info-required", IPP_TAG_KEYWORD, IPP_TAG_PRINTER }, { 0, "blackplot", IPP_TAG_BOOLEAN, IPP_TAG_JOB }, { 0, "blackplot-default", IPP_TAG_BOOLEAN, IPP_TAG_PRINTER }, @@ -71,13 +72,29 @@ static const _ipp_option_t ipp_options[] = { 0, "hue", IPP_TAG_INTEGER, IPP_TAG_JOB }, { 0, "hue-default", IPP_TAG_INTEGER, IPP_TAG_PRINTER }, { 1, "include-schemes", IPP_TAG_NAME, IPP_TAG_OPERATION }, - { 0, "job-impressions", IPP_TAG_INTEGER, IPP_TAG_JOB }, + { 0, "job-account-id", IPP_TAG_NAME, IPP_TAG_JOB }, + { 0, "job-account-id-default",IPP_TAG_NAME, IPP_TAG_PRINTER }, + { 0, "job-accounting-user-id", IPP_TAG_NAME, IPP_TAG_JOB }, + { 0, "job-accounting-user-id-default", IPP_TAG_NAME, IPP_TAG_PRINTER }, + { 0, "job-hold-until", IPP_TAG_KEYWORD, IPP_TAG_JOB }, + { 0, "job-id", IPP_TAG_INTEGER, IPP_TAG_ZERO }, /* never send as option */ + { 0, "job-impressions", IPP_TAG_INTEGER, IPP_TAG_ZERO }, /* never send as option */ + { 0, "job-impressions-completed", IPP_TAG_INTEGER, IPP_TAG_ZERO }, /* never send as option */ { 0, "job-k-limit", IPP_TAG_INTEGER, IPP_TAG_PRINTER }, + { 0, "job-k-octets", IPP_TAG_INTEGER, IPP_TAG_ZERO }, /* never send as option */ + { 0, "job-k-octets-completed",IPP_TAG_INTEGER, IPP_TAG_ZERO }, /* never send as option */ + { 0, "job-media-sheets", IPP_TAG_INTEGER, IPP_TAG_ZERO }, /* never send as option */ + { 0, "job-media-sheets-completed", IPP_TAG_INTEGER, IPP_TAG_ZERO }, /* never send as option */ { 0, "job-page-limit", IPP_TAG_INTEGER, IPP_TAG_PRINTER }, + { 0, "job-password", IPP_TAG_STRING, IPP_TAG_OPERATION }, + { 0, "job-password-encryption", IPP_TAG_KEYWORD, IPP_TAG_OPERATION }, { 0, "job-priority", IPP_TAG_INTEGER, IPP_TAG_JOB }, { 0, "job-quota-period", IPP_TAG_INTEGER, IPP_TAG_PRINTER }, { 1, "job-sheets", IPP_TAG_NAME, IPP_TAG_JOB }, { 1, "job-sheets-default", IPP_TAG_NAME, IPP_TAG_PRINTER }, + { 0, "job-state", IPP_TAG_ENUM, IPP_TAG_ZERO }, /* never send as option */ + { 0, "job-state-message", IPP_TAG_TEXT, IPP_TAG_ZERO }, /* never send as option */ + { 0, "job-state-reasons", IPP_TAG_KEYWORD, IPP_TAG_ZERO }, /* never send as option */ { 0, "job-uuid", IPP_TAG_URI, IPP_TAG_JOB }, { 0, "landscape", IPP_TAG_BOOLEAN, IPP_TAG_JOB }, { 1, "marker-change-time", IPP_TAG_INTEGER, IPP_TAG_PRINTER }, @@ -179,6 +196,9 @@ static const _ipp_option_t ipp_options[] = { 0, "sides", IPP_TAG_KEYWORD, IPP_TAG_JOB, IPP_TAG_DOCUMENT }, { 0, "sides-default", IPP_TAG_KEYWORD, IPP_TAG_PRINTER }, + { 0, "time-at-completed", IPP_TAG_INTEGER, IPP_TAG_ZERO }, /* never send as option */ + { 0, "time-at-creation", IPP_TAG_INTEGER, IPP_TAG_ZERO }, /* never send as option */ + { 0, "time-at-processing", IPP_TAG_INTEGER, IPP_TAG_ZERO }, /* never send as option */ { 0, "wrap", IPP_TAG_BOOLEAN, IPP_TAG_JOB }, { 0, "wrap-default", IPP_TAG_BOOLEAN, IPP_TAG_PRINTER }, { 0, "x-dimension", IPP_TAG_INTEGER, IPP_TAG_JOB, diff --git a/cups/globals.c b/cups/globals.c index bc4191c1d..d7bd5ac50 100644 --- a/cups/globals.c +++ b/cups/globals.c @@ -227,7 +227,7 @@ cups_globals_alloc(void) * Open the registry... */ - strcpy(installdir, "C:/Program Files/cups.org"); + strlcpy(installdir, "C:/Program Files/cups.org", sizeof(installdir)); if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\cups.org", 0, KEY_READ, &key)) diff --git a/cups/http-support.c b/cups/http-support.c index 19538941d..e69b44d05 100644 --- a/cups/http-support.c +++ b/cups/http-support.c @@ -82,6 +82,7 @@ typedef struct _http_uribuf_s /* URI buffer */ char *buffer; /* Pointer to buffer */ size_t bufsize; /* Size of buffer */ int options; /* Options passed to _httpResolveURI */ + const char *resource; /* Resource from URI */ } _http_uribuf_t; @@ -1523,6 +1524,7 @@ _httpResolveURI( uribuf.buffer = resolved_uri; uribuf.bufsize = resolved_size; uribuf.options = options; + uribuf.resource = resource; resolved_uri[0] = '\0'; @@ -2064,8 +2066,14 @@ http_resolve_cb( * Assemble the final device URI... */ - httpAssembleURI(HTTP_URI_CODING_ALL, uribuf->buffer, uribuf->bufsize, scheme, - NULL, hostTarget, ntohs(port), resource); + if ((!strcmp(scheme, "ipp") || !strcmp(scheme, "ipps")) && + !strcmp(uribuf->resource, "/cups")) + httpAssembleURIf(HTTP_URI_CODING_ALL, uribuf->buffer, uribuf->bufsize, + scheme, NULL, hostTarget, ntohs(port), "%s?snmp=false", + resource); + else + httpAssembleURI(HTTP_URI_CODING_ALL, uribuf->buffer, uribuf->bufsize, + scheme, NULL, hostTarget, ntohs(port), resource); DEBUG_printf(("8http_resolve_cb: Resolved URI is \"%s\"...", uribuf->buffer)); } diff --git a/cups/http.c b/cups/http.c index a88a08187..c53465b2f 100644 --- a/cups/http.c +++ b/cups/http.c @@ -2646,7 +2646,8 @@ httpSetLength(http_t *http, /* I - Connection to server */ if (!length) { - strcpy(http->fields[HTTP_FIELD_TRANSFER_ENCODING], "chunked"); + strlcpy(http->fields[HTTP_FIELD_TRANSFER_ENCODING], "chunked", + HTTP_MAX_VALUE); http->fields[HTTP_FIELD_CONTENT_LENGTH][0] = '\0'; } else @@ -2991,8 +2992,11 @@ _httpWait(http_t *http, /* I - Connection to server */ pfd.fd = http->fd; pfd.events = POLLIN; - while ((nfds = poll(&pfd, 1, msec)) < 0 && - (errno == EINTR || errno == EAGAIN)); + do + { + nfds = poll(&pfd, 1, msec); + } + while (nfds < 0 && (errno == EINTR || errno == EAGAIN)); #else do @@ -3469,12 +3473,12 @@ http_debug_hex(const char *prefix, /* I - Prefix for line */ while (j < 16) { - strcpy(ptr, " "); + memcpy(ptr, " ", 3); ptr += 2; j ++; } - strcpy(ptr, " "); + memcpy(ptr, " ", 3); ptr += 2; for (j = 0; j < 16 && (i + j) < bytes; j ++) @@ -4231,6 +4235,8 @@ http_setup_ssl(http_t *http) /* I - Connection to server */ credential->datalen); cupsArrayAdd(names, credential); } + else + free(credential); } } } diff --git a/cups/ipp.c b/cups/ipp.c index 0a1e31c56..9290edbbc 100644 --- a/cups/ipp.c +++ b/cups/ipp.c @@ -623,7 +623,8 @@ ippAddOctetString(ipp_t *ipp, /* I - IPP message */ if (!ipp || !name || group < IPP_TAG_ZERO || - group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE) + group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE || + datalen < 0 || datalen > IPP_MAX_OCTETSTRING) return (NULL); if ((attr = ipp_add_attr(ipp, name, group, IPP_TAG_STRING, 1)) == NULL) @@ -999,7 +1000,8 @@ ippAddString(ipp_t *ipp, /* I - IPP message */ { ipp_tag_t temp_tag; /* Temporary value tag (masked) */ ipp_attribute_t *attr; /* New attribute */ - char code[32]; /* Charset/language code buffer */ + char code[IPP_MAX_LANGUAGE]; + /* Charset/language code buffer */ DEBUG_printf(("ippAddString(ipp=%p, group=%02x(%s), value_tag=%02x(%s), " @@ -2466,13 +2468,25 @@ ippReadIO(void *src, /* I - Data source */ { int n; /* Length of data */ unsigned char *buffer, /* Data buffer */ - string[IPP_MAX_NAME], + string[IPP_MAX_TEXT], /* Small string buffer */ *bufptr; /* Pointer into buffer */ ipp_attribute_t *attr; /* Current attribute */ ipp_tag_t tag; /* Current tag */ ipp_tag_t value_tag; /* Current value tag */ _ipp_value_t *value; /* Current value */ + static const int maxlen[] = /* Maximum length of strings */ + { + IPP_MAX_TEXT - 1, + IPP_MAX_NAME - 1, + 0, + IPP_MAX_KEYWORD - 1, + IPP_MAX_URI - 1, + IPP_MAX_URISCHEME - 1, + IPP_MAX_CHARSET - 1, + IPP_MAX_LANGUAGE - 1, + IPP_MAX_MIMETYPE - 1 + }; DEBUG_printf(("ippReadIO(src=%p, cb=%p, blocking=%d, parent=%p, ipp=%p)", @@ -2913,6 +2927,16 @@ ippReadIO(void *src, /* I - Data source */ case IPP_TAG_CHARSET : case IPP_TAG_LANGUAGE : case IPP_TAG_MIMETYPE : + if (n > maxlen[tag - IPP_TAG_TEXT]) + { + _cupsSetError(IPP_INTERNAL_ERROR, + _("IPP string value too large."), 1); + DEBUG_printf(("1ippReadIO: bad %s value length %d.", + ippTagString(tag), n)); + _cupsBufferRelease((char *)buffer); + return (IPP_ERROR); + } + if (n > 0) { if ((*cb)(src, buffer, n) < n) @@ -3015,6 +3039,21 @@ ippReadIO(void *src, /* I - Data source */ _cupsBufferRelease((char *)buffer); return (IPP_ERROR); } + else if (n > (2 + IPP_MAX_LANGUAGE + IPP_MAX_TEXT)) + { + if (tag == IPP_TAG_TEXTLANG) + _cupsSetError(IPP_INTERNAL_ERROR, + _("IPP textWithLanguage value more than " + "maximum 1090 bytes."), 1); + else + _cupsSetError(IPP_INTERNAL_ERROR, + _("IPP nameWithLanguage value more than " + "maximum 1090 bytes."), 1); + DEBUG_printf(("1ippReadIO: bad stringWithLanguage value " + "length %d.", n)); + _cupsBufferRelease((char *)buffer); + return (IPP_ERROR); + } if ((*cb)(src, buffer, n) < n) { @@ -3048,6 +3087,15 @@ ippReadIO(void *src, /* I - Data source */ _cupsBufferRelease((char *)buffer); return (IPP_ERROR); } + else if (n >= IPP_MAX_LANGUAGE) + { + _cupsSetError(IPP_INTERNAL_ERROR, + _("IPP language length too large."), 1); + DEBUG_printf(("1ippReadIO: bad language value length %d.", + n)); + _cupsBufferRelease((char *)buffer); + return (IPP_ERROR); + } memcpy(string, bufptr + 2, n); string[n] = '\0'; @@ -3065,6 +3113,15 @@ ippReadIO(void *src, /* I - Data source */ _cupsBufferRelease((char *)buffer); return (IPP_ERROR); } + else if (n >= IPP_MAX_TEXT) + { + _cupsSetError(IPP_INTERNAL_ERROR, + _("IPP text length too large."), 1); + DEBUG_printf(("1ippReadIO: bad text value length %d.", + n)); + _cupsBufferRelease((char *)buffer); + return (IPP_ERROR); + } bufptr[2 + n] = '\0'; value->string.text = _cupsStrAlloc((char *)bufptr + 2); @@ -3116,7 +3173,15 @@ ippReadIO(void *src, /* I - Data source */ * we need to carry over... */ - if (n == 0) + if (!attr) + { + _cupsSetError(IPP_INTERNAL_ERROR, + _("IPP memberName with no attribute."), 1); + DEBUG_puts("1ippReadIO: Member name without attribute."); + _cupsBufferRelease((char *)buffer); + return (IPP_ERROR); + } + else if (n == 0) { _cupsSetError(IPP_INTERNAL_ERROR, _("IPP memberName value is empty."), 1); @@ -3146,7 +3211,18 @@ ippReadIO(void *src, /* I - Data source */ break; default : /* Other unsupported values */ + if (tag == IPP_TAG_STRING && n > IPP_MAX_OCTETSTRING) + { + _cupsSetError(IPP_INTERNAL_ERROR, + _("IPP octetString length too large."), 1); + DEBUG_printf(("1ippReadIO: bad octetString value length %d.", + n)); + _cupsBufferRelease((char *)buffer); + return (IPP_ERROR); + } + value->unknown.length = n; + if (n > 0) { if ((value->unknown.data = malloc(n)) == NULL) @@ -4996,7 +5072,8 @@ ipp_free_values(ipp_attribute_t *attr, /* I - Attribute to free values from */ _ipp_value_t *value; /* Current value */ - DEBUG_printf(("4ipp_free_values(attr=%p, element=%d, count=%d)", attr, element, count)); + DEBUG_printf(("4ipp_free_values(attr=%p, element=%d, count=%d)", attr, + element, count)); if (!(attr->value_tag & IPP_TAG_COPY)) { @@ -5008,8 +5085,12 @@ ipp_free_values(ipp_attribute_t *attr, /* I - Attribute to free values from */ { case IPP_TAG_TEXTLANG : case IPP_TAG_NAMELANG : - if (element == 0 && count == attr->num_values && attr->values[0].string.language) + if (element == 0 && count == attr->num_values && + attr->values[0].string.language) + { _cupsStrFree(attr->values[0].string.language); + attr->values[0].string.language = NULL; + } case IPP_TAG_TEXT : case IPP_TAG_NAME : @@ -5023,7 +5104,10 @@ ipp_free_values(ipp_attribute_t *attr, /* I - Attribute to free values from */ for (i = count, value = attr->values + element; i > 0; i --, value ++) + { _cupsStrFree(value->string.text); + value->string.text = NULL; + } break; case IPP_TAG_DEFAULT : @@ -5044,7 +5128,10 @@ ipp_free_values(ipp_attribute_t *attr, /* I - Attribute to free values from */ for (i = count, value = attr->values + element; i > 0; i --, value ++) + { ippDelete(value->collection); + value->collection = NULL; + } break; case IPP_TAG_STRING : @@ -5052,8 +5139,13 @@ ipp_free_values(ipp_attribute_t *attr, /* I - Attribute to free values from */ for (i = count, value = attr->values + element; i > 0; i --, value ++) + { if (value->unknown.data) + { free(value->unknown.data); + value->unknown.data = NULL; + } + } break; } } diff --git a/cups/ipp.h b/cups/ipp.h index 2fb1995e3..2118dd353 100644 --- a/cups/ipp.h +++ b/cups/ipp.h @@ -54,8 +54,16 @@ extern "C" { * Common limits... */ +# define IPP_MAX_CHARSET 64 /* Maximum length of charset values w/nul */ +# define IPP_MAX_KEYWORD 256 /* Maximum length of keyword values w/nul */ +# define IPP_MAX_LANGUAGE 64 /* Maximum length of naturalLanguage values w/nul */ # define IPP_MAX_LENGTH 32767 /* Maximum size of any single value */ -# define IPP_MAX_NAME 256 /* Maximum length of common name values */ +# define IPP_MAX_MIMETYPE 256 /* Maximum length of mimeMediaType values w/nul */ +# define IPP_MAX_NAME 256 /* Maximum length of common name values w/nul */ +# define IPP_MAX_OCTETSTRING 1023 /* Maximum length of octetString values w/o nul */ +# define IPP_MAX_TEXT 1024 /* Maximum length of text values w/nul */ +# define IPP_MAX_URI 1024 /* Maximum length of uri values w/nul */ +# define IPP_MAX_URISCHEME 64 /* Maximum length of uriScheme values w/nul */ # define IPP_MAX_VALUES 8 /* Power-of-2 allocation increment */ diff --git a/cups/langprintf.c b/cups/langprintf.c index 1a9f8b789..f85507547 100644 --- a/cups/langprintf.c +++ b/cups/langprintf.c @@ -3,7 +3,7 @@ * * Localized printf/puts functions for CUPS. * - * Copyright 2007-2011 by Apple Inc. + * Copyright 2007-2012 by Apple Inc. * Copyright 2002-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -304,7 +304,7 @@ _cupsSetLocale(char *argv[]) /* IO - Command-line arguments */ strlcpy(charset, ".UTF-8", sizeof(new_lc_time) - (charset - new_lc_time)); } else - strcpy(new_lc_time, "C"); + strlcpy(new_lc_time, "C", sizeof(new_lc_time)); setlocale(LC_TIME, new_lc_time); #endif /* LC_TIME */ diff --git a/cups/language.c b/cups/language.c index 49f038238..aee4dee3b 100644 --- a/cups/language.c +++ b/cups/language.c @@ -446,7 +446,7 @@ cupsLangGet(const char *language) /* I - Language or locale */ * Set the character set to UTF-8... */ - strcpy(charset, "UTF8"); + strlcpy(charset, "UTF8", sizeof(charset)); /* * Apple's setlocale doesn't give us the user's localization @@ -582,7 +582,7 @@ cupsLangGet(const char *language) /* I - Language or locale */ */ if (!charset[0]) - strcpy(charset, "UTF8"); + strlcpy(charset, "UTF8", sizeof(charset)); /* * Parse the language string passed in to a locale string. "C" is the @@ -597,7 +597,7 @@ cupsLangGet(const char *language) /* I - Language or locale */ if (language == NULL || !language[0] || !strcmp(language, "POSIX")) - strcpy(langname, "C"); + strlcpy(langname, "C", sizeof(langname)); else { /* @@ -646,7 +646,7 @@ cupsLangGet(const char *language) /* I - Language or locale */ if (strlen(langname) != 2) { - strcpy(langname, "C"); + strlcpy(langname, "C", sizeof(langname)); country[0] = '\0'; charset[0] = '\0'; } @@ -701,7 +701,7 @@ cupsLangGet(const char *language) /* I - Language or locale */ if (country[0]) snprintf(real, sizeof(real), "%s_%s", langname, country); else - strcpy(real, langname); + strlcpy(real, langname, sizeof(real)); _cupsMutexLock(&lang_mutex); @@ -847,6 +847,7 @@ _cupsMessageLoad(const char *filename, /* I - Message catalog to load */ *ptr, /* Pointer into buffer */ *temp; /* New string */ int length; /* Length of combined strings */ + size_t ptrlen; /* Length of string */ DEBUG_printf(("4_cupsMessageLoad(filename=\"%s\")", filename)); @@ -978,9 +979,10 @@ _cupsMessageLoad(const char *filename, /* I - Message catalog to load */ */ length = (int)strlen(m->str ? m->str : m->id); + ptrlen = strlen(ptr); if ((temp = realloc(m->str ? m->str : m->id, - length + strlen(ptr) + 1)) == NULL) + length + ptrlen + 1)) == NULL) { if (m->str) free(m->str); @@ -995,25 +997,25 @@ _cupsMessageLoad(const char *filename, /* I - Message catalog to load */ { /* * Copy the new portion to the end of the msgstr string - safe - * to use strcpy because the buffer is allocated to the correct + * to use memcpy because the buffer is allocated to the correct * size... */ m->str = temp; - strcpy(m->str + length, ptr); + memcpy(m->str + length, ptr, ptrlen + 1); } else { /* * Copy the new portion to the end of the msgid string - safe - * to use strcpy because the buffer is allocated to the correct + * to use memcpy because the buffer is allocated to the correct * size... */ m->id = temp; - strcpy(m->id + length, ptr); + memcpy(m->id + length, ptr, ptrlen + 1); } } else if (!strncmp(s, "msgstr", 6) && m) diff --git a/cups/ppd-cache.c b/cups/ppd-cache.c index d39bf14e5..2e7a5d626 100644 --- a/cups/ppd-cache.c +++ b/cups/ppd-cache.c @@ -329,7 +329,7 @@ _ppdCacheCreateWithFile( goto create_error; } - if ((num_sizes = atoi(value)) <= 0 || num_sizes > 65536) + if ((num_sizes = atoi(value)) < 0 || num_sizes > 65536) { DEBUG_printf(("_ppdCacheCreateWithFile: Bad NumSizes value %d on line " "%d.", num_sizes, linenum)); @@ -337,12 +337,15 @@ _ppdCacheCreateWithFile( goto create_error; } - if ((pc->sizes = calloc(num_sizes, sizeof(_pwg_size_t))) == NULL) + if (num_sizes > 0) { - DEBUG_printf(("_ppdCacheCreateWithFile: Unable to allocate %d sizes.", - num_sizes)); - _cupsSetError(IPP_INTERNAL_ERROR, strerror(errno), 0); - goto create_error; + if ((pc->sizes = calloc(num_sizes, sizeof(_pwg_size_t))) == NULL) + { + DEBUG_printf(("_ppdCacheCreateWithFile: Unable to allocate %d sizes.", + num_sizes)); + _cupsSetError(IPP_INTERNAL_ERROR, strerror(errno), 0); + goto create_error; + } } } else if (!_cups_strcasecmp(line, "Size")) @@ -557,6 +560,19 @@ _ppdCacheCreateWithFile( } else if (!_cups_strcasecmp(line, "MaxCopies")) pc->max_copies = atoi(value); + else if (!_cups_strcasecmp(line, "JobAccountId")) + pc->account_id = !_cups_strcasecmp(value, "true"); + else if (!_cups_strcasecmp(line, "JobAccountingUserId")) + pc->accounting_user_id = !_cups_strcasecmp(value, "true"); + else if (!_cups_strcasecmp(line, "JobPassword")) + pc->password = _cupsStrAlloc(value); + else if (!_cups_strcasecmp(line, "Mandatory")) + { + if (pc->mandatory) + _cupsArrayAddStrings(pc->mandatory, value, ' '); + else + pc->mandatory = _cupsArrayNewStrings(value, ' '); + } else { DEBUG_printf(("_ppdCacheCreateWithFile: Unknown %s on line %d.", line, @@ -684,148 +700,145 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd) /* I - PPD file */ * Copy and convert size data... */ - if (ppd->num_sizes == 0) - { - DEBUG_puts("_ppdCacheCreateWithPPD: No page sizes in PPD."); - goto create_error; - } - - if ((pc->sizes = calloc(ppd->num_sizes, sizeof(_pwg_size_t))) == NULL) - { - DEBUG_printf(("_ppdCacheCreateWithPPD: Unable to allocate %d " - "_pwg_size_t's.", ppd->num_sizes)); - goto create_error; - } - - for (i = ppd->num_sizes, pwg_size = pc->sizes, ppd_size = ppd->sizes; - i > 0; - i --, ppd_size ++) + if (ppd->num_sizes > 0) { - /* - * Don't copy over custom size... - */ - - if (!_cups_strcasecmp(ppd_size->name, "Custom")) - continue; - - /* - * Convert the PPD size name to the corresponding PWG keyword name. - */ - - if ((pwg_media = _pwgMediaForPPD(ppd_size->name)) != NULL) + if ((pc->sizes = calloc(ppd->num_sizes, sizeof(_pwg_size_t))) == NULL) { - /* - * Standard name, do we have conflicts? - */ - - for (j = 0; j < pc->num_sizes; j ++) - if (!strcmp(pc->sizes[j].map.pwg, pwg_media->pwg)) - { - pwg_media = NULL; - break; - } + DEBUG_printf(("_ppdCacheCreateWithPPD: Unable to allocate %d " + "_pwg_size_t's.", ppd->num_sizes)); + goto create_error; } - if (pwg_media) + for (i = ppd->num_sizes, pwg_size = pc->sizes, ppd_size = ppd->sizes; + i > 0; + i --, ppd_size ++) { /* - * Standard name and no conflicts, use it! + * Don't copy over custom size... */ - pwg_name = pwg_media->pwg; - new_known_pwg = 1; - } - else - { + if (!_cups_strcasecmp(ppd_size->name, "Custom")) + continue; + /* - * Not a standard name; convert it to a PWG vendor name of the form: - * - * pp_lowerppd_WIDTHxHEIGHTuu + * Convert the PPD size name to the corresponding PWG keyword name. */ - pwg_name = pwg_keyword; - new_known_pwg = 0; + if ((pwg_media = _pwgMediaForPPD(ppd_size->name)) != NULL) + { + /* + * Standard name, do we have conflicts? + */ - pwg_unppdize_name(ppd_size->name, ppd_name, sizeof(ppd_name)); - _pwgGenerateSize(pwg_keyword, sizeof(pwg_keyword), NULL, ppd_name, - _PWG_FROMPTS(ppd_size->width), - _PWG_FROMPTS(ppd_size->length)); - } + for (j = 0; j < pc->num_sizes; j ++) + if (!strcmp(pc->sizes[j].map.pwg, pwg_media->pwg)) + { + pwg_media = NULL; + break; + } + } - /* - * If we have a similar paper with non-zero margins then we only want to - * keep it if it has a larger imageable area length. The NULL check is for - * dimensions that are <= 0... - */ + if (pwg_media) + { + /* + * Standard name and no conflicts, use it! + */ - if ((pwg_media = _pwgMediaForSize(_PWG_FROMPTS(ppd_size->width), - _PWG_FROMPTS(ppd_size->length))) == NULL) - continue; - - new_width = pwg_media->width; - new_length = pwg_media->length; - new_left = _PWG_FROMPTS(ppd_size->left); - new_bottom = _PWG_FROMPTS(ppd_size->bottom); - new_right = _PWG_FROMPTS(ppd_size->width - ppd_size->right); - new_top = _PWG_FROMPTS(ppd_size->length - ppd_size->top); - new_imageable = new_length - new_top - new_bottom; - new_borderless = new_bottom == 0 && new_top == 0 && - new_left == 0 && new_right == 0; - - for (k = pc->num_sizes, similar = 0, old_size = pc->sizes, new_size = NULL; - k > 0 && !similar; - k --, old_size ++) - { - old_imageable = old_size->length - old_size->top - old_size->bottom; - old_borderless = old_size->left == 0 && old_size->bottom == 0 && - old_size->right == 0 && old_size->top == 0; - old_known_pwg = strncmp(old_size->map.pwg, "oe_", 3) && - strncmp(old_size->map.pwg, "om_", 3); - - similar = old_borderless == new_borderless && - _PWG_EQUIVALENT(old_size->width, new_width) && - _PWG_EQUIVALENT(old_size->length, new_length); - - if (similar && - (new_known_pwg || (!old_known_pwg && new_imageable > old_imageable))) + pwg_name = pwg_media->pwg; + new_known_pwg = 1; + } + else { /* - * The new paper has a larger imageable area so it could replace - * the older paper. Regardless of the imageable area, we always - * prefer the size with a well-known PWG name. + * Not a standard name; convert it to a PWG vendor name of the form: + * + * pp_lowerppd_WIDTHxHEIGHTuu */ - new_size = old_size; - _cupsStrFree(old_size->map.ppd); - _cupsStrFree(old_size->map.pwg); + pwg_name = pwg_keyword; + new_known_pwg = 0; + + pwg_unppdize_name(ppd_size->name, ppd_name, sizeof(ppd_name)); + _pwgGenerateSize(pwg_keyword, sizeof(pwg_keyword), NULL, ppd_name, + _PWG_FROMPTS(ppd_size->width), + _PWG_FROMPTS(ppd_size->length)); } - } - if (!similar) - { /* - * The paper was unique enough to deserve its own entry so add it to the - * end. + * If we have a similar paper with non-zero margins then we only want to + * keep it if it has a larger imageable area length. The NULL check is for + * dimensions that are <= 0... */ - new_size = pwg_size ++; - pc->num_sizes ++; - } + if ((pwg_media = _pwgMediaForSize(_PWG_FROMPTS(ppd_size->width), + _PWG_FROMPTS(ppd_size->length))) == NULL) + continue; - if (new_size) - { - /* - * Save this size... - */ + new_width = pwg_media->width; + new_length = pwg_media->length; + new_left = _PWG_FROMPTS(ppd_size->left); + new_bottom = _PWG_FROMPTS(ppd_size->bottom); + new_right = _PWG_FROMPTS(ppd_size->width - ppd_size->right); + new_top = _PWG_FROMPTS(ppd_size->length - ppd_size->top); + new_imageable = new_length - new_top - new_bottom; + new_borderless = new_bottom == 0 && new_top == 0 && + new_left == 0 && new_right == 0; + + for (k = pc->num_sizes, similar = 0, old_size = pc->sizes, new_size = NULL; + k > 0 && !similar; + k --, old_size ++) + { + old_imageable = old_size->length - old_size->top - old_size->bottom; + old_borderless = old_size->left == 0 && old_size->bottom == 0 && + old_size->right == 0 && old_size->top == 0; + old_known_pwg = strncmp(old_size->map.pwg, "oe_", 3) && + strncmp(old_size->map.pwg, "om_", 3); + + similar = old_borderless == new_borderless && + _PWG_EQUIVALENT(old_size->width, new_width) && + _PWG_EQUIVALENT(old_size->length, new_length); + + if (similar && + (new_known_pwg || (!old_known_pwg && new_imageable > old_imageable))) + { + /* + * The new paper has a larger imageable area so it could replace + * the older paper. Regardless of the imageable area, we always + * prefer the size with a well-known PWG name. + */ + + new_size = old_size; + _cupsStrFree(old_size->map.ppd); + _cupsStrFree(old_size->map.pwg); + } + } + + if (!similar) + { + /* + * The paper was unique enough to deserve its own entry so add it to the + * end. + */ + + new_size = pwg_size ++; + pc->num_sizes ++; + } + + if (new_size) + { + /* + * Save this size... + */ - new_size->map.ppd = _cupsStrAlloc(ppd_size->name); - new_size->map.pwg = _cupsStrAlloc(pwg_name); - new_size->width = new_width; - new_size->length = new_length; - new_size->left = new_left; - new_size->bottom = new_bottom; - new_size->right = new_right; - new_size->top = new_top; + new_size->map.ppd = _cupsStrAlloc(ppd_size->name); + new_size->map.pwg = _cupsStrAlloc(pwg_name); + new_size->width = new_width; + new_size->length = new_length; + new_size->left = new_left; + new_size->bottom = new_bottom; + new_size->right = new_right; + new_size->top = new_top; + } } } @@ -1367,6 +1380,23 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd) /* I - PPD file */ pc->max_copies = 9999; /* + * cupsJobAccountId, cupsJobAccountingUserId, cupsJobPassword, and + * cupsMandatory. + */ + + if ((ppd_attr = ppdFindAttr(ppd, "cupsJobAccountId", NULL)) != NULL) + pc->account_id = !_cups_strcasecmp(ppd_attr->value, "true"); + + if ((ppd_attr = ppdFindAttr(ppd, "cupsJobAccountingUserId", NULL)) != NULL) + pc->accounting_user_id = !_cups_strcasecmp(ppd_attr->value, "true"); + + if ((ppd_attr = ppdFindAttr(ppd, "cupsJobPassword", NULL)) != NULL) + pc->password = _cupsStrAlloc(ppd_attr->value); + + if ((ppd_attr = ppdFindAttr(ppd, "cupsMandatory", NULL)) != NULL) + pc->mandatory = _cupsArrayNewStrings(ppd_attr->value, ' '); + + /* * Return the cache data... */ @@ -1466,6 +1496,10 @@ _ppdCacheDestroy(_ppd_cache_t *pc) /* I - PPD cache and mapping data */ cupsArrayDelete(pc->prefilters); cupsArrayDelete(pc->finishings); + _cupsStrFree(pc->password); + + cupsArrayDelete(pc->mandatory); + free(pc); } @@ -2358,6 +2392,22 @@ _ppdCacheWriteFile( cupsFilePrintf(fp, "MaxCopies %d\n", pc->max_copies); /* + * Accounting/quota/PIN/managed printing values... + */ + + cupsFilePrintf(fp, "AccountId %s\n", pc->account_id ? "true" : "false"); + cupsFilePrintf(fp, "AccountingUserId %s\n", + pc->accounting_user_id ? "true" : "false"); + + if (pc->password) + cupsFilePutConf(fp, "Password", pc->password); + + for (value = (char *)cupsArrayFirst(pc->mandatory); + value; + value = (char *)cupsArrayNext(pc->mandatory)) + cupsFilePutConf(fp, "Mandatory", value); + + /* * IPP attributes, if any... */ diff --git a/cups/ppd-private.h b/cups/ppd-private.h index 426c74ff8..1eaa2c816 100644 --- a/cups/ppd-private.h +++ b/cups/ppd-private.h @@ -49,7 +49,7 @@ extern "C" { * Constants... */ -# define _PPD_CACHE_VERSION 3 /* Version number in cache file */ +# define _PPD_CACHE_VERSION 4 /* Version number in cache file */ /* @@ -141,7 +141,11 @@ struct _ppd_cache_s /**** PPD cache and PWG conversion data ****/ *prefilters; /* cupsPreFilter values */ int single_file; /* cupsSingleFile value */ cups_array_t *finishings; /* cupsIPPFinishings values */ - int max_copies; /* cupsMaxCopies value */ + int max_copies, /* cupsMaxCopies value */ + account_id, /* cupsJobAccountId value */ + accounting_user_id; /* cupsJobAccountingUserId value */ + char *password; /* cupsJobPassword value */ + cups_array_t *mandatory; /* cupsMandatory value */ }; diff --git a/cups/ppd.c b/cups/ppd.c index 1ff51b244..fe58fcfe0 100644 --- a/cups/ppd.c +++ b/cups/ppd.c @@ -1264,7 +1264,7 @@ _ppdOpen( ppd->patches = temp; - strcpy(ppd->patches + strlen(ppd->patches), string); + memcpy(ppd->patches + strlen(ppd->patches), string, strlen(string) + 1); } } else if (!strcmp(keyword, "OpenUI")) @@ -1378,7 +1378,7 @@ _ppdOpen( */ if (!_cups_strcasecmp(name, "PageRegion")) - strcpy(custom_name, "CustomPageSize"); + strlcpy(custom_name, "CustomPageSize", sizeof(custom_name)); else snprintf(custom_name, sizeof(custom_name), "Custom%s", name); @@ -1944,9 +1944,9 @@ _ppdOpen( cupsCharsetToUTF8((cups_utf8_t *)choice->text, text, sizeof(choice->text), encoding); else if (!strcmp(name, "True")) - strcpy(choice->text, _("Yes")); + strlcpy(choice->text, _("Yes"), sizeof(choice->text)); else if (!strcmp(name, "False")) - strcpy(choice->text, _("No")); + strlcpy(choice->text, _("No"), sizeof(choice->text)); else strlcpy(choice->text, name, sizeof(choice->text)); diff --git a/cups/pwg-media.c b/cups/pwg-media.c index f4850dcf6..222b6ef7c 100644 --- a/cups/pwg-media.c +++ b/cups/pwg-media.c @@ -486,7 +486,7 @@ _pwgInitSize(_pwg_size_t *size, /* I - Size to initialize */ if ((media = ippFindAttribute(job, "PageSize", IPP_TAG_NAME)) == NULL) media = ippFindAttribute(job, "PageRegion", IPP_TAG_NAME); - if (media) + if (media && media->values[0].string.text) { const char *name = media->values[0].string.text; /* Name string */ diff --git a/cups/request.c b/cups/request.c index a10852fa8..51457df84 100644 --- a/cups/request.c +++ b/cups/request.c @@ -51,9 +51,9 @@ /* * 'cupsDoFileRequest()' - Do an IPP request with a file. * - * This function sends the IPP request to the specified server, retrying - * and authenticating as necessary. The request is freed with @link ippDelete@ - * after receiving a valid IPP response. + * This function sends the IPP request and attached file to the specified + * server, retrying and authenticating as necessary. The request is freed with + * @link ippDelete@. */ ipp_t * /* O - Response data */ @@ -102,14 +102,14 @@ cupsDoFileRequest(http_t *http, /* I - Connection to server or @code CUPS_HT /* * 'cupsDoIORequest()' - Do an IPP request with file descriptors. * - * This function sends the IPP request to the specified server, retrying - * and authenticating as necessary. The request is freed with ippDelete() - * after receiving a valid IPP response. + * This function sends the IPP request with the optional input file "infile" to + * the specified server, retrying and authenticating as necessary. The request + * is freed with @link ippDelete@. * - * If "infile" is a valid file descriptor, cupsDoIORequest() copies + * If "infile" is a valid file descriptor, @code cupsDoIORequest@ copies * all of the data from the file after the IPP request message. * - * If "outfile" is a valid file descriptor, cupsDoIORequest() copies + * If "outfile" is a valid file descriptor, @code cupsDoIORequest@ copies * all of the data after the IPP response message to the file. * * @since CUPS 1.3/OS X 10.5@ @@ -309,8 +309,7 @@ cupsDoIORequest(http_t *http, /* I - Connection to server or @code CUPS_HTTP * 'cupsDoRequest()' - Do an IPP request. * * This function sends the IPP request to the specified server, retrying - * and authenticating as necessary. The request is freed with ippDelete() - * after receiving a valid IPP response. + * and authenticating as necessary. The request is freed with @link ippDelete@. */ ipp_t * /* O - Response data */ @@ -331,9 +330,9 @@ cupsDoRequest(http_t *http, /* I - Connection to server or @code CUPS_HTTP_ * 'cupsGetResponse()' - Get a response to an IPP request. * * Use this function to get the response for an IPP request sent using - * cupsSendDocument() or cupsSendRequest(). For requests that return - * additional data, use httpRead() after getting a successful response, - * otherwise call httpFlush() to complete the response processing. + * @link cupsSendRequest@. For requests that return additional data, use + * @link cupsReadResponseData@ after getting a successful response, + * otherwise call @link httpFlush@ to complete the response processing. * * @since CUPS 1.4/OS X 10.6@ */ @@ -481,7 +480,8 @@ cupsGetResponse(http_t *http, /* I - Connection to server or @code CUPS_HTTP /* - * 'cupsLastError()' - Return the last IPP status code. + * 'cupsLastError()' - Return the last IPP status code received on the current + * thread. */ ipp_status_t /* O - IPP status code from last request */ @@ -492,7 +492,8 @@ cupsLastError(void) /* - * 'cupsLastErrorString()' - Return the last IPP status-message. + * 'cupsLastErrorString()' - Return the last IPP status-message received on the + * current thread. * * @since CUPS 1.2/OS X 10.5@ */ @@ -537,8 +538,9 @@ _cupsNextDelay(int current, /* I - Current delay value or 0 */ /* * 'cupsReadResponseData()' - Read additional data after the IPP response. * - * This function is used after cupsGetResponse() to read the PPD or document - * files for CUPS_GET_PPD and CUPS_GET_DOCUMENT requests, respectively. + * This function is used after @link cupsGetResponse@ to read the PPD or document + * files from @code CUPS_GET_PPD@ and @code CUPS_GET_DOCUMENT@ requests, + * respectively. * * @since CUPS 1.4/OS X 10.6@ */ @@ -579,13 +581,17 @@ cupsReadResponseData( /* * 'cupsSendRequest()' - Send an IPP request. * - * Use httpWrite() to write any additional data (document, PPD file, etc.) - * for the request, cupsGetResponse() to get the IPP response, and httpRead() - * to read any additional data following the response. Only one request can be - * sent/queued at a time. + * Use @link cupsWriteRequestData@ to write any additional data (document, PPD + * file, etc.) for the request, @link cupsGetResponse@ to get the IPP response, + * and @link cupsReadResponseData@ to read any additional data following the + * response. Only one request can be sent/queued at a time per @code http_t@ + * connection. + * + * Returns the initial HTTP status code, which will be @code HTTP_CONTINUE@ + * on a successful send of the request. * - * Unlike cupsDoFileRequest(), cupsDoIORequest(), and cupsDoRequest(), the - * request is not freed. + * Note: Unlike @link cupsDoFileRequest@, @link cupsDoIORequest@, and + * @link cupsDoRequest@, the request is NOT freed with @link ippDelete@. * * @since CUPS 1.4/OS X 10.6@ */ diff --git a/cups/snprintf.c b/cups/snprintf.c index fcebf895e..9271052d5 100644 --- a/cups/snprintf.c +++ b/cups/snprintf.c @@ -3,7 +3,7 @@ * * snprintf functions for CUPS. * - * Copyright 2007-2010 by Apple Inc. + * Copyright 2007-2012 by Apple Inc. * Copyright 1997-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -48,6 +48,7 @@ _cups_vsnprintf(char *buffer, /* O - Output buffer */ char tformat[100], /* Temporary format string for sprintf() */ *tptr, /* Pointer into temporary format */ temp[1024]; /* Buffer for formatted numbers */ + size_t templen; /* Length of "temp" */ char *s; /* Pointer to string */ int slen; /* Length of string */ int bytes; /* Total number of bytes needed */ @@ -183,20 +184,21 @@ _cups_vsnprintf(char *buffer, /* O - Output buffer */ break; sprintf(temp, tformat, va_arg(ap, double)); + templen = strlen(temp): - bytes += (int)strlen(temp); + bytes += (int)templen; if (bufptr) { - if ((bufptr + strlen(temp)) > bufend) + if ((bufptr + templen) > bufend) { - strncpy(bufptr, temp, (size_t)(bufend - bufptr)); + strlcpy(bufptr, temp, (size_t)(bufend - bufptr)); bufptr = bufend; } else { - strcpy(bufptr, temp); - bufptr += strlen(temp); + memcpy(bufptr, temp, templen + 1); + bufptr += templen; } } break; @@ -213,20 +215,21 @@ _cups_vsnprintf(char *buffer, /* O - Output buffer */ break; sprintf(temp, tformat, va_arg(ap, int)); + templen = strlen(temp): - bytes += (int)strlen(temp); + bytes += (int)templen; if (bufptr) { - if ((bufptr + strlen(temp)) > bufend) + if ((bufptr + templen) > bufend) { - strncpy(bufptr, temp, (size_t)(bufend - bufptr)); + strlcpy(bufptr, temp, (size_t)(bufend - bufptr)); bufptr = bufend; } else { - strcpy(bufptr, temp); - bufptr += strlen(temp); + memcpy(bufptr, temp, templen + 1); + bufptr += templen; } } break; @@ -236,20 +239,21 @@ _cups_vsnprintf(char *buffer, /* O - Output buffer */ break; sprintf(temp, tformat, va_arg(ap, void *)); + templen = strlen(temp): - bytes += (int)strlen(temp); + bytes += (int)templen; if (bufptr) { - if ((bufptr + strlen(temp)) > bufend) + if ((bufptr + templen) > bufend) { - strncpy(bufptr, temp, (size_t)(bufend - bufptr)); + strlcpy(bufptr, temp, (size_t)(bufend - bufptr)); bufptr = bufend; } else { - strcpy(bufptr, temp); - bufptr += strlen(temp); + memcpy(bufptr, temp, templen + 1); + bufptr += templen; } } break; diff --git a/cups/string.c b/cups/string.c index 538a26386..ad5b5bc61 100644 --- a/cups/string.c +++ b/cups/string.c @@ -3,7 +3,7 @@ * * String functions for CUPS. * - * Copyright 2007-2011 by Apple Inc. + * Copyright 2007-2012 by Apple Inc. * Copyright 1997-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -69,6 +69,7 @@ static int compare_sp_items(_cups_sp_item_t *a, _cups_sp_item_t *b); char * /* O - String pointer */ _cupsStrAlloc(const char *s) /* I - String */ { + size_t slen; /* Length of string */ _cups_sp_item_t *item, /* String pool item */ *key; /* Search key */ @@ -128,7 +129,8 @@ _cupsStrAlloc(const char *s) /* I - String */ * Not found, so allocate a new one... */ - item = (_cups_sp_item_t *)calloc(1, sizeof(_cups_sp_item_t) + strlen(s)); + slen = strlen(s); + item = (_cups_sp_item_t *)calloc(1, sizeof(_cups_sp_item_t) + slen); if (!item) { _cupsMutexUnlock(&sp_mutex); @@ -137,7 +139,7 @@ _cupsStrAlloc(const char *s) /* I - String */ } item->ref_count = 1; - strcpy(item->str, s); + memcpy(item->str, s, slen + 1); #ifdef DEBUG_GUARDS item->guard = _CUPS_STR_GUARD; @@ -588,16 +590,18 @@ _cups_strcpy(char *dst, /* I - Destination string */ char * /* O - New string pointer */ _cups_strdup(const char *s) /* I - String to duplicate */ { - char *t; /* New string pointer */ + char *t; /* New string pointer */ + size_t slen; /* Length of string */ - if (s == NULL) + if (!s) return (NULL); - if ((t = malloc(strlen(s) + 1)) == NULL) + slen = strlen(s); + if ((t = malloc(slen + 1)) == NULL) return (NULL); - return (strcpy(t, s)); + return (memcpy(t, s, slen + 1)); } #endif /* !HAVE_STRDUP */ diff --git a/cups/testarray.c b/cups/testarray.c index 2e254c24e..9f7eb2a71 100644 --- a/cups/testarray.c +++ b/cups/testarray.c @@ -3,7 +3,7 @@ * * Array test program for CUPS. * - * Copyright 2007-2010 by Apple Inc. + * Copyright 2007-2012 by Apple Inc. * Copyright 1997-2006 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -139,7 +139,7 @@ main(int argc, /* I - Number of command-line arguments */ /* * cupsArrayCount() */ - + fputs("cupsArrayCount: ", stdout); if (cupsArrayCount(array) == 4) puts("PASS"); @@ -319,7 +319,7 @@ main(int argc, /* I - Number of command-line arguments */ * the same buffer in the first place... :) */ - strcpy(word, text); + strlcpy(word, text, sizeof(word)); /* * Grab the next word and compare... diff --git a/cups/testhttp.c b/cups/testhttp.c index a133f8233..089e4d28c 100644 --- a/cups/testhttp.c +++ b/cups/testhttp.c @@ -3,7 +3,7 @@ * * HTTP test program for CUPS. * - * Copyright 2007-2011 by Apple Inc. + * Copyright 2007-2012 by Apple Inc. * Copyright 1997-2006 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -218,7 +218,7 @@ main(int argc, /* I - Number of command-line arguments */ fputs("httpGetDateString()/httpGetDateTime(): ", stdout); start = time(NULL); - strcpy(buffer, httpGetDateString(start)); + strlcpy(buffer, httpGetDateString(start), sizeof(buffer)); current = httpGetDateTime(buffer); i = (int)(current - start); diff --git a/cups/testi18n.c b/cups/testi18n.c index 725c01b2b..d8eb4ba0f 100644 --- a/cups/testi18n.c +++ b/cups/testi18n.c @@ -3,7 +3,7 @@ * * Internationalization test for CUPS. * - * Copyright 2007-2011 by Apple Inc. + * Copyright 2007-2012 by Apple Inc. * Copyright 1997-2006 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -282,7 +282,7 @@ main(int argc, /* I - Argument Count */ fputs("cupsCharsetToUTF8(CUPS_ISO8859_1): ", stdout); - strcpy(legsrc, legdest); + strlcpy(legsrc, legdest, sizeof(legsrc)); len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_ISO8859_1); if (len != strlen((char *)utf8latin)) @@ -333,7 +333,7 @@ main(int argc, /* I - Argument Count */ fputs("cupsCharsetToUTF8(CUPS_ISO8859_7): ", stdout); - strcpy(legsrc, legdest); + strlcpy(legsrc, legdest, sizeof(legsrc)); len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_ISO8859_7); if (len != strlen((char *)utf8greek)) @@ -379,7 +379,7 @@ main(int argc, /* I - Argument Count */ fputs("cupsCharsetToUTF8(CUPS_WINDOWS_932): ", stdout); - strcpy(legsrc, legdest); + strlcpy(legsrc, legdest, sizeof(legsrc)); len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_WINDOWS_932); if (len != strlen((char *)utf8japan)) @@ -426,7 +426,7 @@ main(int argc, /* I - Argument Count */ #ifndef __linux fputs("cupsCharsetToUTF8(CUPS_EUC_JP): ", stdout); - strcpy(legsrc, legdest); + strlcpy(legsrc, legdest, sizeof(legsrc)); len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_EUC_JP); if (len != strlen((char *)utf8japan)) @@ -473,7 +473,7 @@ main(int argc, /* I - Argument Count */ fputs("cupsCharsetToUTF8(CUPS_WINDOWS_950): ", stdout); - strcpy(legsrc, legdest); + strlcpy(legsrc, legdest, sizeof(legsrc)); len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_WINDOWS_950); if (len != strlen((char *)utf8taiwan)) @@ -519,7 +519,7 @@ main(int argc, /* I - Argument Count */ fputs("cupsCharsetToUTF8(CUPS_EUC_TW): ", stdout); - strcpy(legsrc, legdest); + strlcpy(legsrc, legdest, sizeof(legsrc)); len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_EUC_TW); if (len != strlen((char *)utf8taiwan)) diff --git a/cups/testppd.c b/cups/testppd.c index 5e291ce83..ef88425dc 100644 --- a/cups/testppd.c +++ b/cups/testppd.c @@ -3,7 +3,7 @@ * * PPD test program for CUPS. * - * Copyright 2007-2011 by Apple Inc. + * Copyright 2007-2012 by Apple Inc. * Copyright 1997-2006 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -150,6 +150,7 @@ main(int argc, /* I - Number of command-line arguments */ maxsize, /* Maximum size */ *size; /* Current size */ ppd_attr_t *attr; /* Current attribute */ + _ppd_cache_t *pc; /* PPD cache */ status = 0; @@ -897,7 +898,7 @@ main(int argc, /* I - Number of command-line arguments */ if ((realsize = readlink(filename, realfile, sizeof(realfile) - 1)) < 0) - strcpy(realfile, "Unknown"); + strlcpy(realfile, "Unknown", sizeof(realfile)); else realfile[realsize] = '\0'; @@ -1073,6 +1074,15 @@ main(int argc, /* I - Number of command-line arguments */ attr = (ppd_attr_t *)cupsArrayNext(ppd->sorted_attrs)) printf(" *%s %s/%s: \"%s\"\n", attr->name, attr->spec, attr->text, attr->value ? attr->value : ""); + + puts("\nPPD Cache:"); + if ((pc = _ppdCacheCreateWithPPD(ppd)) == NULL) + printf(" Unable to create: %s\n", cupsLastErrorString()); + else + { + _ppdCacheWriteFile(pc, "t.cache", NULL); + puts(" Wrote t.cache."); + } } if (!strncmp(argv[1], "-d", 2)) diff --git a/cups/usersys.c b/cups/usersys.c index 7aee0007f..989700726 100644 --- a/cups/usersys.c +++ b/cups/usersys.c @@ -358,7 +358,7 @@ cupsSetServer(const char *server) /* I - Server name */ } if (cg->server[0] == '/') - strcpy(cg->servername, "localhost"); + strlcpy(cg->servername, "localhost", sizeof(cg->servername)); else strlcpy(cg->servername, cg->server, sizeof(cg->servername)); } @@ -949,7 +949,7 @@ cups_read_client_conf( value = NULL; if (cg->server[0] == '/') - strcpy(cg->servername, "localhost"); + strlcpy(cg->servername, "localhost", sizeof(cg->servername)); else strlcpy(cg->servername, cg->server, sizeof(cg->servername)); } @@ -1035,7 +1035,7 @@ cups_read_client_conf( * Use the default "unknown" user name... */ - strcpy(cg->user, "unknown"); + strlcpy(cg->user, "unknown", sizeof(cg->user)); } } } diff --git a/cups/util.c b/cups/util.c index a73130763..c9826549c 100644 --- a/cups/util.c +++ b/cups/util.c @@ -605,7 +605,7 @@ cupsGetJobs2(http_t *http, /* I - Connection to server or @code CUPS_HTTP_D } } else - strcpy(uri, "ipp://localhost/"); + strlcpy(uri, "ipp://localhost/", sizeof(uri)); if (!http) if ((http = _cupsConnect()) == NULL) @@ -1059,7 +1059,7 @@ cupsGetPPD3(http_t *http, /* I - HTTP connection or @code CUPS_HTTP_DEFAUL DEBUG_printf(("2cupsGetPPD3: Local hostname=\"%s\"", localhost)); if (!_cups_strcasecmp(localhost, hostname)) - strcpy(hostname, "localhost"); + strlcpy(hostname, "localhost", sizeof(hostname)); /* * Get the hostname and port number we are connected to... |