From da00323434b33f7cd32474061a06d575d8ab46c5 Mon Sep 17 00:00:00 2001 From: msweet Date: Mon, 4 Nov 2013 23:47:03 +0000 Subject: [PATCH] cups.org: gunzip bug prevents use of some gzip'd PPD files (and other issues) git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@11373 a1ca3aef-8c08-0410-bb20-df032aa958be --- cups/file.c | 70 ++++++++++---------------------------------- cups/http-addr.c | 7 +++-- cups/http-addrlist.c | 32 ++++++++------------ cups/md5.c | 42 +++++++++++++------------- scheduler/conf.c | 48 +++++++++--------------------- 5 files changed, 66 insertions(+), 133 deletions(-) diff --git a/cups/file.c b/cups/file.c index ef8c77209..9b1f592a9 100644 --- a/cups/file.c +++ b/cups/file.c @@ -1,61 +1,21 @@ /* * "$Id$" * - * File functions for CUPS. + * File functions for CUPS. * - * Since stdio files max out at 256 files on many systems, we have to - * write similar functions without this limit. At the same time, using - * our own file functions allows us to provide transparent support of - * gzip'd print files, PPD files, etc. + * Since stdio files max out at 256 files on many systems, we have to + * write similar functions without this limit. At the same time, using + * our own file functions allows us to provide transparent support of + * gzip'd print files, PPD files, etc. * - * 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: - * - * _cupsFileCheck() - Check the permissions of the given filename. - * _cupsFileCheckFilter() - Report file check results as CUPS filter messages. - * cupsFileClose() - Close a CUPS file. - * cupsFileCompression() - Return whether a file is compressed. - * cupsFileEOF() - Return the end-of-file status. - * cupsFileFind() - Find a file using the specified path. - * cupsFileFlush() - Flush pending output. - * cupsFileGetChar() - Get a single character from a file. - * cupsFileGetConf() - Get a line from a configuration file. - * cupsFileGetLine() - Get a CR and/or LF-terminated line that may - * contain binary data. - * cupsFileGets() - Get a CR and/or LF-terminated line. - * cupsFileLock() - Temporarily lock access to a file. - * cupsFileNumber() - Return the file descriptor associated with a CUPS - * file. - * cupsFileOpen() - Open a CUPS file. - * cupsFileOpenFd() - Open a CUPS file using a file descriptor. - * cupsFilePeekChar() - Peek at the next character from a file. - * cupsFilePrintf() - Write a formatted string. - * cupsFilePutChar() - Write a character. - * cupsFilePutConf() - Write a configuration line. - * cupsFilePuts() - Write a string. - * cupsFileRead() - Read from a file. - * cupsFileRewind() - Set the current file position to the beginning of - * the file. - * cupsFileSeek() - Seek in a file. - * cupsFileStderr() - Return a CUPS file associated with stderr. - * cupsFileStdin() - Return a CUPS file associated with stdin. - * cupsFileStdout() - Return a CUPS file associated with stdout. - * cupsFileTell() - Return the current file position. - * cupsFileUnlock() - Unlock access to a file. - * cupsFileWrite() - Write to a file. - * cups_compress() - Compress a buffer of data. - * cups_fill() - Fill the input buffer. - * cups_open() - Safely open a file for writing. - * cups_read() - Read from a file descriptor. - * cups_write() - Write to a file descriptor. + * 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/". */ /* @@ -2429,8 +2389,8 @@ cups_fill(cups_file_t *fp) /* I - CUPS file */ } else { - tcrc = (((((trailer[3] << 8) | trailer[2]) << 8) | trailer[1]) << 8) | - trailer[0]; + tcrc = ((((((uLong)trailer[3] << 8) | (uLong)trailer[2]) << 8) | + (uLong)trailer[1]) << 8) | (uLong)trailer[0]; if (tcrc != fp->crc) { @@ -2438,7 +2398,7 @@ cups_fill(cups_file_t *fp) /* I - CUPS file */ * Bad CRC, mark end-of-file... */ - DEBUG_printf(("9cups_fill: tcrc=%08x, fp->crc=%08x", + DEBUG_printf(("9cups_fill: tcrc=%08x != fp->crc=%08x", (unsigned int)tcrc, (unsigned int)fp->crc)); fp->eof = 1; diff --git a/cups/http-addr.c b/cups/http-addr.c index 01eb74db5..130d0a748 100644 --- a/cups/http-addr.c +++ b/cups/http-addr.c @@ -746,8 +746,9 @@ httpGetHostByName(const char *name) /* I - Hostname or IP address */ if (ip[0] > 255 || ip[1] > 255 || ip[2] > 255 || ip[3] > 255) return (NULL); /* Invalid byte ranges! */ - cg->ip_addr = htonl(((((((ip[0] << 8) | ip[1]) << 8) | ip[2]) << 8) | - ip[3])); + cg->ip_addr = htonl((((((((unsigned)ip[0] << 8) | (unsigned)ip[1]) << 8) | + (unsigned)ip[2]) << 8) | + (unsigned)ip[3])); /* * Fill in the host entry and return it... @@ -818,7 +819,7 @@ httpGetHostname(http_t *http, /* I - HTTP connection or NULL */ if (!s || slen <= 1) return (NULL); - + if (gethostname(s, slen) < 0) strlcpy(s, "localhost", slen); diff --git a/cups/http-addrlist.c b/cups/http-addrlist.c index b6cbc1f3f..287692ff3 100644 --- a/cups/http-addrlist.c +++ b/cups/http-addrlist.c @@ -1,25 +1,16 @@ /* * "$Id$" * - * HTTP address list routines for CUPS. + * HTTP address list routines for CUPS. * - * 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: - * - * httpAddrConnect() - Connect to any of the addresses in the list. - * httpAddrConnect2() - Connect to any of the addresses in the list with a - * timeout and optional cancel. - * httpAddrCopyList() - Copy an address list. - * httpAddrFreeList() - Free an address list. - * httpAddrGetList() - Get a list of addresses for a hostname. + * 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/". */ /* @@ -639,9 +630,10 @@ httpAddrGetList(const char *hostname, /* I - Hostname, IP address, or NULL for p return (NULL); first->addr.ipv4.sin_family = AF_INET; - first->addr.ipv4.sin_addr.s_addr = htonl(((((((ip[0] << 8) | - ip[1]) << 8) | - ip[2]) << 8) | ip[3])); + first->addr.ipv4.sin_addr.s_addr = htonl((((((((unsigned)ip[0] << 8) | + (unsigned)ip[1]) << 8) | + (unsigned)ip[2]) << 8) | + (unsigned)ip[3])); first->addr.ipv4.sin_port = htons(portnum); } } diff --git a/cups/md5.c b/cups/md5.c index 1f46a957c..843890d4d 100644 --- a/cups/md5.c +++ b/cups/md5.c @@ -1,31 +1,30 @@ /* * "$Id$" * - * Private MD5 implementation for CUPS. + * Private MD5 implementation for CUPS. * - * Copyright 2007-2010 by Apple Inc. - * Copyright 2005 by Easy Software Products + * Copyright 2007-2013 by Apple Inc. + * Copyright 2005 by Easy Software Products + * Copyright (C) 1999 Aladdin Enterprises. All rights reserved. * - * Copyright (C) 1999 Aladdin Enterprises. All rights reserved. + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * L. Peter Deutsch - * ghost@aladdin.com + * L. Peter Deutsch + * ghost@aladdin.com */ /* Independent implementation of MD5 (RFC 1321). @@ -133,7 +132,8 @@ _cups_md5_process(_cups_md5_state_t *pms, const unsigned char *data /*[64]*/) int i; for (i = 0; i < 16; ++i, xp += 4) - X[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24); + X[i] = (unsigned)xp[0] + ((unsigned)xp[1] << 8) + + ((unsigned)xp[2] << 16) + ((unsigned)xp[3] << 24); #else /* !ARCH_IS_BIG_ENDIAN */ diff --git a/scheduler/conf.c b/scheduler/conf.c index a12793f7d..eb26aff8e 100644 --- a/scheduler/conf.c +++ b/scheduler/conf.c @@ -1,39 +1,16 @@ /* * "$Id$" * - * Configuration routines for the CUPS scheduler. + * Configuration 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: - * - * cupsdAddAlias() - Add a host alias. - * cupsdCheckPermissions() - Fix the mode and ownership of a file or - * directory. - * cupsdDefaultAuthType() - Get the default AuthType. - * cupsdFreeAliases() - Free all of the alias entries. - * cupsdReadConfiguration() - Read the cupsd.conf file. - * get_address() - Get an address + port number from a line. - * get_addr_and_mask() - Get an IP address and netmask. - * mime_error_cb() - Log a MIME error. - * parse_aaa() - Parse authentication, authorization, and access - * control lines. - * parse_fatal_errors() - Parse FatalErrors values in a string. - * parse_groups() - Parse system group names in a string. - * parse_protocols() - Parse browse protocols in a string. - * parse_variable() - Parse a variable line. - * read_cupsd_conf() - Read the cupsd.conf configuration file. - * read_cups_files_conf() - Read the cups-files.conf configuration file. - * read_location() - Read a definition. - * read_policy() - Read a definition. - * set_policy_defaults() - Set default policy values as needed. + * 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/". */ /* @@ -1815,7 +1792,8 @@ get_addr_and_mask(const char *value, /* I - String from config file */ * Merge everything into a 32-bit IPv4 address in ip[3]... */ - ip[3] = (((((val[0] << 8) | val[1]) << 8) | val[2]) << 8) | val[3]; + ip[3] = ((((((unsigned)val[0] << 8) | (unsigned)val[1]) << 8) | + (unsigned)val[2]) << 8) | (unsigned)val[3]; if (ipcount < 4) mask[3] = (0xffffffff << (32 - 8 * ipcount)) & 0xffffffff; @@ -1883,7 +1861,8 @@ get_addr_and_mask(const char *value, /* I - String from config file */ * Merge everything into a 32-bit IPv4 address in ip[3]... */ - ip[3] = (((((val[0] << 8) | val[1]) << 8) | val[2]) << 8) | val[3]; + ip[3] = ((((((unsigned)val[0] << 8) | (unsigned)val[1]) << 8) | + (unsigned)val[2]) << 8) | (unsigned)val[3]; if (ipcount < 4) mask[3] = (0xffffffff << (32 - 8 * ipcount)) & 0xffffffff; @@ -1910,7 +1889,8 @@ get_addr_and_mask(const char *value, /* I - String from config file */ mask + 3) != 4) return (0); - mask[3] |= ((((mask[0] << 8) | mask[1]) << 8) | mask[2]) << 8; + mask[3] |= (((((unsigned)mask[0] << 8) | (unsigned)mask[1]) << 8) | + (unsigned)mask[2]) << 8; mask[0] = mask[1] = mask[2] = 0; } else -- 2.39.2