From 6f83172dc0c7a5bdcd9861c201c17ad7f6713bc3 Mon Sep 17 00:00:00 2001 From: mike Date: Tue, 3 Feb 2004 04:08:18 +0000 Subject: [PATCH] Mirror 1.1.x changes. git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/branches/branch-1.2@4034 7a7537e8-13f0-0310-91df-b6672ffda945 --- CHANGES-1.1.txt | 19 +++++++++++ berkeley/lpc.c | 14 +++++--- cups/emit.c | 14 +++++--- cups/ppd.c | 32 +++++++++---------- filter/raster.c | 32 +++++++++++++++---- pdftops/PSOutputDev.cxx | 4 +-- scheduler/client.c | 71 ++++++++++++----------------------------- scheduler/cups-polld.c | 33 ++----------------- scheduler/file.c | 14 ++++++-- scheduler/ipp.c | 6 ++-- 10 files changed, 120 insertions(+), 119 deletions(-) diff --git a/CHANGES-1.1.txt b/CHANGES-1.1.txt index 296ddb2fc..ce68871a5 100644 --- a/CHANGES-1.1.txt +++ b/CHANGES-1.1.txt @@ -3,6 +3,25 @@ CHANGES-1.1.txt CHANGES IN CUPS V1.1.21rc1 + - The PPD conformance tests did not catch group + translation strings that exceeded the maximum allowed + size (STR #454) + - Updated the client code in the scheduler to close the + client connection on errors rather than shutting down + the receive end of the socket; this caused resource + problems on some systems (STR #434) + - cups-polld didn't compile on Tru64 5.1B (STR #436) + - "lpc stat" crashed if the device URI was empty (STR + #548) + - The scheduler did not compile without zlib (STR #433) + - std:floor() cast needed on IRIX 6.5 with SGI C++ + compiler (STR #497) + - cupsRasterReadPixels() and cupsRasterWritePixels() did + not handle EAGAIN and EINTR properly (STR #473) + - RequiresPageRegion should not be consulted for Manual + Feed (STR #514) + - International characters were not substituted in + banner files properly (STR #468) - Updated pdftops to Xpdf 2.03 code to fix printing bugs (STR #470) - The Digest authentication code did not include the diff --git a/berkeley/lpc.c b/berkeley/lpc.c index 5f43330d9..d738d4301 100644 --- a/berkeley/lpc.c +++ b/berkeley/lpc.c @@ -1,5 +1,5 @@ /* - * "$Id: lpc.c,v 1.11.2.7 2003/07/20 12:51:39 mike Exp $" + * "$Id: lpc.c,v 1.11.2.8 2004/02/03 04:08:18 mike Exp $" * * "lpc" command for the Common UNIX Printing System (CUPS). * @@ -220,7 +220,8 @@ show_status(http_t *http, /* I - HTTP connection to server */ *jattr; /* Current job attribute */ cups_lang_t *language; /* Default language */ char *printer, /* Printer name */ - *device; /* Device URI */ + *device, /* Device URI */ + *delimiter; /* Char search result */ ipp_pstate_t pstate; /* Printer state */ int accepting; /* Is printer accepting jobs? */ int jobcount; /* Count of current jobs */ @@ -453,8 +454,11 @@ show_status(http_t *http, /* I - HTTP connection to server */ * Just show the method... */ - *strchr(device, ':') = '\0'; - printf("\tprinter is on device \'%s\' speed -1\n", device); + if ((delimiter = strchr(device, ':')) != NULL ) + { + *delimiter = '\0'; + printf("\tprinter is on device \'%s\' speed -1\n", device); + } } printf("\tqueuing is %sabled\n", accepting ? "en" : "dis"); @@ -477,5 +481,5 @@ show_status(http_t *http, /* I - HTTP connection to server */ /* - * End of "$Id: lpc.c,v 1.11.2.7 2003/07/20 12:51:39 mike Exp $". + * End of "$Id: lpc.c,v 1.11.2.8 2004/02/03 04:08:18 mike Exp $". */ diff --git a/cups/emit.c b/cups/emit.c index aa188d8c2..8f19cb9ad 100644 --- a/cups/emit.c +++ b/cups/emit.c @@ -1,5 +1,5 @@ /* - * "$Id: emit.c,v 1.23.2.12 2003/09/20 15:47:33 mike Exp $" + * "$Id: emit.c,v 1.23.2.13 2004/02/03 04:08:18 mike Exp $" * * PPD code emission routines for the Common UNIX Printing System (CUPS). * @@ -676,8 +676,14 @@ ppd_handle_media(ppd_file_t *ppd) ppdMarkOption(ppd, "PageRegion", size->name); - if ((rpr && rpr->value && !strcmp(rpr->value, "False")) || - (!rpr && !ppd->num_filters)) + /* + * RequiresPageRegion does not apply to manual feed so we need to + * check that we are not doing manual feed before unmarking PageRegion. + */ + + if (!(manual_feed && !strcasecmp(manual_feed->choice, "True")) && + ((rpr && rpr->value && !strcmp(rpr->value, "False")) || + (!rpr && !ppd->num_filters))) { /* * Either the PPD file specifies no PageRegion code or the PPD file @@ -713,5 +719,5 @@ ppd_sort(ppd_choice_t **c1, /* I - First choice */ /* - * End of "$Id: emit.c,v 1.23.2.12 2003/09/20 15:47:33 mike Exp $". + * End of "$Id: emit.c,v 1.23.2.13 2004/02/03 04:08:18 mike Exp $". */ diff --git a/cups/ppd.c b/cups/ppd.c index 634971c83..3f8def5bc 100644 --- a/cups/ppd.c +++ b/cups/ppd.c @@ -1,5 +1,5 @@ /* - * "$Id: ppd.c,v 1.51.2.61 2003/11/17 02:29:53 mike Exp $" + * "$Id: ppd.c,v 1.51.2.62 2004/02/03 04:08:18 mike Exp $" * * PPD file routines for the Common UNIX Printing System (CUPS). * @@ -619,11 +619,7 @@ ppdOpen(FILE *fp) /* I - File to read from */ cupsLangString(language, CUPS_MSG_GENERAL)); if (group == NULL) - { - ppd_status = PPD_ALLOC_ERROR; - goto error; - } DEBUG_printf(("Adding to group %s...\n", group->text)); option = ppd_get_option(group, keyword); @@ -856,8 +852,6 @@ ppdOpen(FILE *fp) /* I - File to read from */ { DEBUG_puts("Unable to get general group!"); - ppd_status = PPD_ALLOC_ERROR; - goto error; } @@ -1026,11 +1020,7 @@ ppdOpen(FILE *fp) /* I - File to read from */ cupsLangString(language, CUPS_MSG_GENERAL)); if (group == NULL) - { - ppd_status = PPD_ALLOC_ERROR; - goto error; - } DEBUG_printf(("Adding to group %s...\n", group->text)); option = ppd_get_option(group, name); @@ -1128,11 +1118,7 @@ ppdOpen(FILE *fp) /* I - File to read from */ group = ppd_get_group(ppd, "JCL", "JCL"); if (group == NULL) - { - ppd_status = PPD_ALLOC_ERROR; - goto error; - } /* * Add an option record to the current JCLs... @@ -1237,6 +1223,9 @@ ppdOpen(FILE *fp) /* I - File to read from */ group = ppd_get_group(ppd, string, sptr); + if (group == NULL) + goto error; + ppd_free(string); string = NULL; } @@ -2484,6 +2473,13 @@ ppd_get_group(ppd_file_t *ppd, /* I - PPD file */ { DEBUG_printf(("Adding group %s...\n", name)); + if (ppd_conform == PPD_CONFORM_STRICT && strlen(text) >= sizeof(group->text)) + { + ppd_status = PPD_ILLEGAL_TRANSLATION; + + return (NULL); + } + if (ppd->num_groups == 0) group = malloc(sizeof(ppd_group_t)); else @@ -2491,7 +2487,11 @@ ppd_get_group(ppd_file_t *ppd, /* I - PPD file */ (ppd->num_groups + 1) * sizeof(ppd_group_t)); if (group == NULL) + { + ppd_status = PPD_ALLOC_ERROR; + return (NULL); + } ppd->groups = group; group += ppd->num_groups; @@ -3022,5 +3022,5 @@ ppd_read(FILE *fp, /* I - File to read from */ /* - * End of "$Id: ppd.c,v 1.51.2.61 2003/11/17 02:29:53 mike Exp $". + * End of "$Id: ppd.c,v 1.51.2.62 2004/02/03 04:08:18 mike Exp $". */ diff --git a/filter/raster.c b/filter/raster.c index 8d2bb87d5..de577431d 100644 --- a/filter/raster.c +++ b/filter/raster.c @@ -1,5 +1,5 @@ /* - * "$Id: raster.c,v 1.2.2.7 2003/02/11 18:23:32 mike Exp $" + * "$Id: raster.c,v 1.2.2.8 2004/02/03 04:08:18 mike Exp $" * * Raster file routines for the Common UNIX Printing System (CUPS). * @@ -824,8 +824,19 @@ cups_read(int fd, /* I - File descriptor */ for (total = 0; total < bytes; total += count, buf += count) - if ((count = read(fd, buf, bytes - total)) <= 0) - return (-1); + { + count = read(fd, buf, bytes - total); + + if (count == 0) + return (0); + else if (count < 0) + { + if (errno != EAGAIN && errno != EINTR) + count = 0; + else + return (-1); + } + } return (total); } @@ -845,13 +856,22 @@ cups_write(int fd, /* I - File descriptor */ for (total = 0; total < bytes; total += count, buf += count) - if ((count = write(fd, buf, bytes - total)) <= 0) - return (-1); + { + count = write(fd, buf, bytes - total); + + if (count < 0) + { + if (errno != EAGAIN && errno != EINTR) + count = 0; + else + return (-1); + } + } return (total); } /* - * End of "$Id: raster.c,v 1.2.2.7 2003/02/11 18:23:32 mike Exp $". + * End of "$Id: raster.c,v 1.2.2.8 2004/02/03 04:08:18 mike Exp $". */ diff --git a/pdftops/PSOutputDev.cxx b/pdftops/PSOutputDev.cxx index 64748e463..423a5b5c5 100644 --- a/pdftops/PSOutputDev.cxx +++ b/pdftops/PSOutputDev.cxx @@ -1933,8 +1933,8 @@ void PSOutputDev::startPage(int pageNum, GfxState *state) { x2 = (int)(state->getX2() + 0.5); y2 = (int)(state->getY2() + 0.5); writePSFmt("%%%%PageBoundingBox: %d %d %d %d\n", - (int)floor(x1), (int)floor(y1), - (int)ceil(x2), (int)ceil(y2)); + (int)floor((float)x1), (int)floor((float)y1), + (int)ceil((float)x2), (int)ceil((float)y2)); writePS("%%BeginPageSetup\n"); width = x2 - x1; height = y2 - y1; diff --git a/scheduler/client.c b/scheduler/client.c index 02f08a785..acc70e518 100644 --- a/scheduler/client.c +++ b/scheduler/client.c @@ -1,5 +1,5 @@ /* - * "$Id: client.c,v 1.91.2.73 2003/09/29 14:51:59 mike Exp $" + * "$Id: client.c,v 1.91.2.74 2004/02/03 04:08:18 mike Exp $" * * Client routines for the Common UNIX Printing System (CUPS) scheduler. * @@ -33,7 +33,6 @@ * SendError() - Send an error message via HTTP. * SendFile() - Send a file via HTTP. * SendHeader() - Send an HTTP request. - * ShutdownClient() - Shutdown the receiving end of a connection. * UpdateCGI() - Read status messages from CGI scripts and programs. * WriteClient() - Write data to a client as needed. * check_if_modified() - Decode an "If-Modified-Since" line. @@ -912,8 +911,8 @@ ReadClient(client_t *con) /* I - Client to read from */ case 1 : LogMessage(L_ERROR, "Bad request line \"%s\"!", line); SendError(con, HTTP_BAD_REQUEST); - ShutdownClient(con); - return (1); + CloseClient(con); + return (0); case 2 : con->http.version = HTTP_0_9; break; @@ -922,8 +921,8 @@ ReadClient(client_t *con) /* I - Client to read from */ { LogMessage(L_ERROR, "Bad request line \"%s\"!", line); SendError(con, HTTP_BAD_REQUEST); - ShutdownClient(con); - return (1); + CloseClient(con); + return (0); } if (major < 2) @@ -937,8 +936,8 @@ ReadClient(client_t *con) /* I - Client to read from */ else { SendError(con, HTTP_NOT_SUPPORTED); - ShutdownClient(con); - return (1); + CloseClient(con); + return (0); } break; } @@ -977,8 +976,8 @@ ReadClient(client_t *con) /* I - Client to read from */ LogMessage(L_ERROR, "Bad URI \"%s\" in request!", con->uri); SendError(con, HTTP_METHOD_NOT_ALLOWED); - ShutdownClient(con); - return (1); + CloseClient(con); + return (0); } /* @@ -1011,8 +1010,8 @@ ReadClient(client_t *con) /* I - Client to read from */ { LogMessage(L_ERROR, "Bad operation \"%s\"!", operation); SendError(con, HTTP_BAD_REQUEST); - ShutdownClient(con); - return (1); + CloseClient(con); + return (0); } con->start = time(NULL); @@ -1040,8 +1039,8 @@ ReadClient(client_t *con) /* I - Client to read from */ if (status != HTTP_OK && status != HTTP_CONTINUE) { SendError(con, HTTP_BAD_REQUEST); - ShutdownClient(con); - return (1); + CloseClient(con); + return (0); } break; @@ -1219,8 +1218,8 @@ ReadClient(client_t *con) /* I - Client to read from */ LogMessage(L_DEBUG2, "ReadClient: Unauthorized request for %s...\n", con->uri); SendError(con, status); - ShutdownClient(con); - return (1); + CloseClient(con); + return (0); } if (con->http.expect) @@ -1591,8 +1590,8 @@ ReadClient(client_t *con) /* I - Client to read from */ case HTTP_DELETE : case HTTP_TRACE : SendError(con, HTTP_NOT_IMPLEMENTED); - ShutdownClient(con); - return (1); + CloseClient(con); + return (0); case HTTP_HEAD : if (strncmp(con->uri, "/printers/", 10) == 0 && @@ -1850,8 +1849,8 @@ ReadClient(client_t *con) /* I - Client to read from */ return (0); } - ShutdownClient(con); - return (1); + CloseClient(con); + return (0); } else if (ipp_state != IPP_DATA) break; @@ -2253,36 +2252,6 @@ SendHeader(client_t *con, /* I - Client to send to */ } -/* - * 'ShutdownClient()' - Shutdown the receiving end of a connection. - */ - -void -ShutdownClient(client_t *con) /* I - Client connection */ -{ - /* - * Shutdown the receiving end of the socket, since the client - * still needs to read the error message... - */ - - shutdown(con->http.fd, 0); - con->http.used = 0; - - /* - * Update the activity time so that we timeout after 30 seconds rather - * then the current Timeout setting (300 by default). This prevents - * some DoS situations... - */ - - con->http.activity = time(NULL) - Timeout + 30; - - LogMessage(L_DEBUG2, "ShutdownClient: Removing fd %d from InputSet...", - con->http.fd); - - FD_CLR(con->http.fd, InputSet); -} - - /* * 'UpdateCGI()' - Read status messages from CGI scripts and programs. */ @@ -3496,5 +3465,5 @@ CDSAWriteFunc(SSLConnectionRef connection, /* I - SSL/TLS connection */ /* - * End of "$Id: client.c,v 1.91.2.73 2003/09/29 14:51:59 mike Exp $". + * End of "$Id: client.c,v 1.91.2.74 2004/02/03 04:08:18 mike Exp $". */ diff --git a/scheduler/cups-polld.c b/scheduler/cups-polld.c index b962641fe..87a17637a 100644 --- a/scheduler/cups-polld.c +++ b/scheduler/cups-polld.c @@ -1,5 +1,5 @@ /* - * "$Id: cups-polld.c,v 1.5.2.16 2003/04/29 19:35:14 mike Exp $" + * "$Id: cups-polld.c,v 1.5.2.17 2004/02/03 04:08:18 mike Exp $" * * Polling daemon for the Common UNIX Printing System (CUPS). * @@ -31,6 +31,7 @@ * Include necessary headers... */ +#include #include #include #include @@ -38,34 +39,6 @@ #include -/* - * Some OS's don't have hstrerror(), most notably Solaris... - */ - -#ifndef HAVE_HSTRERROR -# define hstrerror cups_hstrerror - -const char * /* O - Error string */ -cups_hstrerror(int error) /* I - Error number */ -{ - static const char * const errors[] = - { - "OK", - "Host not found.", - "Try again.", - "Unrecoverable lookup error.", - "No data associated with name." - }; - - - if (error < 0 || error > 4) - return ("Unknown hostname lookup error."); - else - return (errors[error]); -} -#endif /* !HAVE_HSTRERROR */ - - /* * Local functions... */ @@ -423,5 +396,5 @@ poll_server(http_t *http, /* I - HTTP connection */ /* - * End of "$Id: cups-polld.c,v 1.5.2.16 2003/04/29 19:35:14 mike Exp $". + * End of "$Id: cups-polld.c,v 1.5.2.17 2004/02/03 04:08:18 mike Exp $". */ diff --git a/scheduler/file.c b/scheduler/file.c index 683670820..eda0db41c 100644 --- a/scheduler/file.c +++ b/scheduler/file.c @@ -1,5 +1,5 @@ /* - * "$Id: file.c,v 1.1.2.5 2003/11/04 16:37:55 mike Exp $" + * "$Id: file.c,v 1.1.2.6 2004/02/03 04:08:18 mike Exp $" * * File functions for the Common UNIX Printing System (CUPS). * @@ -551,7 +551,9 @@ cupsFileSeek(cups_file_t *fp, /* I - CUPS file */ fp->pos = pos; fp->ptr = NULL; fp->end = NULL; +#ifdef HAVE_LIBZ fp->eof = 0; +#endif /* HAVE_LIBZ */ } } else if (pos >= (fp->pos + bytes)) @@ -577,6 +579,9 @@ cupsFileSeek(cups_file_t *fp, /* I - CUPS file */ fp->pos = pos; fp->ptr = NULL; fp->end = NULL; +#ifdef HAVE_LIBZ + fp->eof = 0; +#endif /* HAVE_LIBZ */ } } else @@ -587,6 +592,9 @@ cupsFileSeek(cups_file_t *fp, /* I - CUPS file */ */ fp->ptr = fp->buf + pos - fp->pos; +#ifdef HAVE_LIBZ + fp->eof = 0; +#endif /* HAVE_LIBZ */ } return (pos); @@ -638,8 +646,10 @@ static int /* O - Number of bytes or -1 */ cups_fill(cups_file_t *fp) /* I - CUPS file */ { int bytes; /* Number of bytes read */ +#ifdef HAVE_LIBZ const unsigned char *ptr, /* Pointer into buffer */ *end; /* End of buffer */ +#endif /* HAVE_LIBZ */ /* @@ -971,5 +981,5 @@ cups_write(int fd, /* I - File descriptor */ /* - * End of "$Id: file.c,v 1.1.2.5 2003/11/04 16:37:55 mike Exp $". + * End of "$Id: file.c,v 1.1.2.6 2004/02/03 04:08:18 mike Exp $". */ diff --git a/scheduler/ipp.c b/scheduler/ipp.c index ce99cf6bc..cd0363457 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -1,5 +1,5 @@ /* - * "$Id: ipp.c,v 1.127.2.75 2003/10/22 14:24:41 mike Exp $" + * "$Id: ipp.c,v 1.127.2.76 2004/02/03 04:08:18 mike Exp $" * * IPP routines for the Common UNIX Printing System (CUPS) scheduler. * @@ -2446,7 +2446,7 @@ copy_banner(client_t *con, /* I - Client connection */ cupsFilePutChar(out, *p); } else if (*p < 32 || *p > 126) - cupsFilePrintf(out, "\\%03o", *p); + cupsFilePrintf(out, "\\%03o", *p & 255); else cupsFilePutChar(out, *p); } @@ -6865,5 +6865,5 @@ validate_user(client_t *con, /* I - Client connection */ /* - * End of "$Id: ipp.c,v 1.127.2.75 2003/10/22 14:24:41 mike Exp $". + * End of "$Id: ipp.c,v 1.127.2.76 2004/02/03 04:08:18 mike Exp $". */ -- 2.39.5