From 076239869a921fff635f11ef9d459eea9a4d8b9f Mon Sep 17 00:00:00 2001 From: msweet Date: Fri, 14 Feb 2014 20:09:01 +0000 Subject: [PATCH] Fix build errors on Fedora. git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@11594 a1ca3aef-8c08-0410-bb20-df032aa958be --- backend/dnssd.c | 4 +- backend/ieee1284.c | 13 +++---- backend/snmp.c | 11 +++--- backend/testbackend.c | 2 +- backend/usb-libusb.c | 48 +++++++----------------- cgi-bin/admin.c | 8 ++-- cgi-bin/help-index.c | 2 +- cgi-bin/ipp-var.c | 12 ++---- cgi-bin/var.c | 2 +- cups/adminutil.c | 4 +- cups/auth.c | 2 +- cups/dest.c | 13 +++---- cups/emit.c | 32 +++++++--------- cups/file.c | 14 +++---- cups/http-addr.c | 42 ++++++++++----------- cups/http-support.c | 15 +++----- cups/http.c | 8 ++-- cups/ipp-support.c | 37 +++++++------------ cups/ipp.c | 20 +++++----- cups/localize.c | 6 +-- cups/md5.c | 4 +- cups/ppd-cache.c | 2 +- cups/sidechannel.c | 6 +-- cups/snmp.c | 2 +- cups/string.c | 2 +- cups/tempfile.c | 30 ++++++--------- cups/testppd.c | 1 + cups/tls-gnutls.c | 83 +++++++++++++++++++++++++++++++++++++++++- cups/transcode.c | 4 +- cups/util.c | 2 +- filter/raster.c | 8 ++-- filter/rastertoepson.c | 2 +- notifier/dbus.c | 16 ++++---- scheduler/cert.c | 8 ++-- scheduler/client.c | 17 ++++----- scheduler/cups-exec.c | 1 + scheduler/cups-lpd.c | 4 +- scheduler/cupsd.h | 3 +- scheduler/file.c | 32 +++++----------- scheduler/ipp.c | 28 +++++--------- scheduler/log.c | 2 +- scheduler/printers.c | 9 ++--- scheduler/process.c | 18 ++++----- scheduler/select.c | 14 +++---- scheduler/statbuf.c | 2 +- scheduler/type.c | 6 +-- test/ippfind.c | 2 +- test/ipptool.c | 4 +- 48 files changed, 293 insertions(+), 314 deletions(-) diff --git a/backend/dnssd.c b/backend/dnssd.c index fad831f7f..44084e3ed 100644 --- a/backend/dnssd.c +++ b/backend/dnssd.c @@ -1107,7 +1107,7 @@ query_callback( data ++; if (data < datanext) - memcpy(value, data, datanext - data); + memcpy(value, data, (size_t)(datanext - data)); value[datanext - data] = '\0'; fprintf(stderr, "DEBUG2: query_callback: \"%s=%s\".\n", @@ -1198,7 +1198,7 @@ query_callback( * Assume the first word is the make... */ - memcpy(make_and_model, model, ptr - model); + memcpy(make_and_model, model, (size_t)(ptr - model)); make_and_model[ptr - model] = '\0'; snprintf(device_id, sizeof(device_id), "MFG:%s;MDL:%s", diff --git a/backend/ieee1284.c b/backend/ieee1284.c index 48be693f7..b4ded43ee 100644 --- a/backend/ieee1284.c +++ b/backend/ieee1284.c @@ -141,8 +141,7 @@ backendGetDeviceID( * Read the 1284 device ID... */ - if ((length = read(devparportfd, device_id, - device_id_size - 1)) >= 2) + if ((length = read(devparportfd, device_id, (size_t)device_id_size - 1)) >= 2) { device_id[length] = '\0'; got_id = 1; @@ -171,8 +170,7 @@ backendGetDeviceID( * bytes. The 1284 spec says the length is stored MSB first... */ - length = (((unsigned)device_id[0] & 255) << 8) + - ((unsigned)device_id[1] & 255); + length = (int)((((unsigned)device_id[0] & 255) << 8) + ((unsigned)device_id[1] & 255)); /* * Check to see if the length is larger than our buffer; first @@ -181,8 +179,7 @@ backendGetDeviceID( */ if (length > device_id_size || length < 14) - length = (((unsigned)device_id[1] & 255) << 8) + - ((unsigned)device_id[0] & 255); + length = (int)((((unsigned)device_id[1] & 255) << 8) + ((unsigned)device_id[0] & 255)); if (length > device_id_size) length = device_id_size; @@ -214,7 +211,7 @@ backendGetDeviceID( length -= 2; - memmove(device_id, device_id + 2, length); + memmove(device_id, device_id + 2, (size_t)length); device_id[length] = '\0'; } } @@ -280,7 +277,7 @@ backendGetDeviceID( */ if (make_model) - backendGetMakeModel(device_id, make_model, make_model_size); + backendGetMakeModel(device_id, make_model, (size_t)make_model_size); /* * Then generate a device URI... diff --git a/backend/snmp.c b/backend/snmp.c index 688997b78..876ca6520 100644 --- a/backend/snmp.c +++ b/backend/snmp.c @@ -506,17 +506,16 @@ fix_make_model( make_model[0] = 'H'; make_model[1] = 'P'; make_model[2] = ' '; - strlcpy(make_model + 3, mmptr, make_model_size - 3); + strlcpy(make_model + 3, mmptr, (size_t)make_model_size - 3); } else if (!_cups_strncasecmp(old_make_model, "deskjet", 7)) - snprintf(make_model, make_model_size, "HP DeskJet%s", old_make_model + 7); + snprintf(make_model, (size_t)make_model_size, "HP DeskJet%s", old_make_model + 7); else if (!_cups_strncasecmp(old_make_model, "officejet", 9)) - snprintf(make_model, make_model_size, "HP OfficeJet%s", old_make_model + 9); + snprintf(make_model, (size_t)make_model_size, "HP OfficeJet%s", old_make_model + 9); else if (!_cups_strncasecmp(old_make_model, "stylus_pro_", 11)) - snprintf(make_model, make_model_size, "EPSON Stylus Pro %s", - old_make_model + 11); + snprintf(make_model, (size_t)make_model_size, "EPSON Stylus Pro %s", old_make_model + 11); else - strlcpy(make_model, old_make_model, make_model_size); + strlcpy(make_model, old_make_model, (size_t)make_model_size); if ((mmptr = strstr(make_model, ", Inc.,")) != NULL) { diff --git a/backend/testbackend.c b/backend/testbackend.c index 190e65673..046fc3e30 100644 --- a/backend/testbackend.c +++ b/backend/testbackend.c @@ -671,7 +671,7 @@ walk_cb(const char *oid, /* I - OID */ } else { - memcpy(temp, data, datalen); + memcpy(temp, data, (size_t)datalen); temp[datalen] = '\0'; } diff --git a/backend/usb-libusb.c b/backend/usb-libusb.c index 0a9162645..2a0884ce2 100644 --- a/backend/usb-libusb.c +++ b/backend/usb-libusb.c @@ -1,35 +1,15 @@ /* * "$Id$" * - * LIBUSB interface code for CUPS. + * LIBUSB interface code for CUPS. * - * Copyright 2007-2013 by Apple Inc. + * Copyright 2007-2014 by Apple Inc. * - * 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: - * - * list_devices() - List the available printers. - * print_device() - Print a file to a USB device. - * close_device() - Close the connection to the USB printer. - * compare_quirks() - Compare two quirks entries. - * find_device() - Find or enumerate USB printers. - * find_quirks() - Find the quirks for the given printer, if any. - * get_device_id() - Get the IEEE-1284 device ID for the printer. - * list_cb() - List USB printers for discovery. - * load_quirks() - Load all quirks files in the /usr/share/cups/usb - * directory. - * make_device_uri() - Create a device URI for a USB printer. - * open_device() - Open a connection to the USB printer. - * print_cb() - Find a USB printer for printing. - * read_thread() - Thread to read the backchannel data on. - * sidechannel_thread() - Handle side-channel requests. - * soft_reset() - Send a soft reset to the device. - * soft_reset_printer() - Do the soft reset request specific to printers + * 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/". */ /* @@ -920,8 +900,8 @@ find_device(usb_cb_t cb, /* I - Callback function */ fprintf(stderr, "DEBUG: Printer does not report class 7 and/or " "subclass 1 but works as a printer anyway\n"); - read_endp = -1; - write_endp = -1; + read_endp = 0xff; + write_endp = 0xff; for (endp = 0, endpptr = altptr->endpoint; endp < altptr->bNumEndpoints; @@ -1085,8 +1065,7 @@ get_device_id(usb_printer_t *printer, /* I - Printer */ * bytes. The 1284 spec says the length is stored MSB first... */ - length = (((unsigned)buffer[0] & 255) << 8) | - ((unsigned)buffer[1] & 255); + length = (int)((((unsigned)buffer[0] & 255) << 8) | ((unsigned)buffer[1] & 255)); /* * Check to see if the length is larger than our buffer or less than 14 bytes @@ -1097,8 +1076,7 @@ get_device_id(usb_printer_t *printer, /* I - Printer */ */ if (length > bufsize || length < 14) - length = (((unsigned)buffer[1] & 255) << 8) | - ((unsigned)buffer[0] & 255); + length = (int)((((unsigned)buffer[1] & 255) << 8) | ((unsigned)buffer[0] & 255)); if (length > bufsize) length = bufsize; @@ -1120,7 +1098,7 @@ get_device_id(usb_printer_t *printer, /* I - Printer */ * nul-terminate. */ - memmove(buffer, buffer + 2, length); + memmove(buffer, buffer + 2, (size_t)length); buffer[length] = '\0'; return (0); @@ -1734,7 +1712,7 @@ static void *read_thread(void *reference) { fprintf(stderr, "DEBUG: Read %d bytes of back-channel data...\n", (int)rbytes); - cupsBackChannelWrite((const char *)readbuffer, rbytes, 1.0); + cupsBackChannelWrite((const char *)readbuffer, (size_t)rbytes, 1.0); } else if (readstatus == LIBUSB_ERROR_TIMEOUT) fputs("DEBUG: Got USB transaction timeout during read.\n", stderr); diff --git a/cgi-bin/admin.c b/cgi-bin/admin.c index b10180e86..6c794d5de 100644 --- a/cgi-bin/admin.c +++ b/cgi-bin/admin.c @@ -4076,7 +4076,7 @@ get_option_value( if ((val = cgiGetVariable(keyword)) == NULL) return (NULL); - snprintf(bufptr, bufend - bufptr, "%s%s=", prefix, cparam->name); + snprintf(bufptr, (size_t)(bufend - bufptr), "%s%s=", prefix, cparam->name); bufptr += strlen(bufptr); prefix = " "; @@ -4090,7 +4090,7 @@ get_option_value( number > cparam->maximum.custom_real) return (NULL); - snprintf(bufptr, bufend - bufptr, "%g", number); + snprintf(bufptr, (size_t)(bufend - bufptr), "%g", number); break; case PPD_CUSTOM_INT : @@ -4100,7 +4100,7 @@ get_option_value( integer > cparam->maximum.custom_int) return (NULL); - snprintf(bufptr, bufend - bufptr, "%ld", integer); + snprintf(bufptr, (size_t)(bufend - bufptr), "%ld", integer); break; case PPD_CUSTOM_POINTS : @@ -4118,7 +4118,7 @@ get_option_value( number_points > cparam->maximum.custom_points) return (NULL); - snprintf(bufptr, bufend - bufptr, "%g%s", number, uval); + snprintf(bufptr, (size_t)(bufend - bufptr), "%g%s", number, uval); break; case PPD_CUSTOM_PASSCODE : diff --git a/cgi-bin/help-index.c b/cgi-bin/help-index.c index c63e21cca..844482451 100644 --- a/cgi-bin/help-index.c +++ b/cgi-bin/help-index.c @@ -1163,7 +1163,7 @@ help_load_file( wordlen = (int)(ptr - text); - memcpy(temp, text, wordlen); + memcpy(temp, text, (size_t)wordlen); temp[wordlen] = '\0'; ptr --; diff --git a/cgi-bin/ipp-var.c b/cgi-bin/ipp-var.c index 46fdfab02..764cf8a4d 100644 --- a/cgi-bin/ipp-var.c +++ b/cgi-bin/ipp-var.c @@ -902,7 +902,7 @@ cgiRewriteURL(const char *uri, /* I - Current URI */ * Make URI relative to the current server... */ - strlcpy(url, resource, urlsize); + strlcpy(url, resource, (size_t)urlsize); } else { @@ -911,17 +911,13 @@ cgiRewriteURL(const char *uri, /* I - Current URI */ */ if (userpass[0]) - snprintf(url, urlsize, "%s://%s@%s:%d%s", - ishttps ? "https" : "http", - userpass, hostname, port, resource); + snprintf(url, (size_t)urlsize, "%s://%s@%s:%d%s", ishttps ? "https" : "http", userpass, hostname, port, resource); else - snprintf(url, urlsize, "%s://%s:%d%s", - ishttps ? "https" : "http", - hostname, port, resource); + snprintf(url, (size_t)urlsize, "%s://%s:%d%s", ishttps ? "https" : "http", hostname, port, resource); } } else - strlcpy(url, uri, urlsize); + strlcpy(url, uri, (size_t)urlsize); return (url); } diff --git a/cgi-bin/var.c b/cgi-bin/var.c index 90ab8bb52..6972eef02 100644 --- a/cgi-bin/var.c +++ b/cgi-bin/var.c @@ -821,7 +821,7 @@ cgi_initialize_multipart( */ write(fd, line, 8192); - memmove(line, line + 8192, ptr - line - 8192); + memmove(line, line + 8192, (size_t)(ptr - line - 8192)); ptr -= 8192; } } diff --git a/cups/adminutil.c b/cups/adminutil.c index 6a50fbea9..81234f083 100644 --- a/cups/adminutil.c +++ b/cups/adminutil.c @@ -41,7 +41,7 @@ static int do_samba_command(const char *command, FILE *logfile); static http_status_t get_cupsd_conf(http_t *http, _cups_globals_t *cg, time_t last_update, char *name, - int namelen, int *remote); + size_t namelen, int *remote); static void invalidate_cupsd_cache(_cups_globals_t *cg); static void write_option(cups_file_t *dstfp, int order, const char *name, const char *text, @@ -2109,7 +2109,7 @@ get_cupsd_conf( _cups_globals_t *cg, /* I - Global data */ time_t last_update, /* I - Last update time for file */ char *name, /* I - Filename buffer */ - int namesize, /* I - Size of filename buffer */ + size_t namesize, /* I - Size of filename buffer */ int *remote) /* O - Remote file? */ { int fd; /* Temporary file descriptor */ diff --git a/cups/auth.c b/cups/auth.c index f002ea001..bc4fad6c8 100644 --- a/cups/auth.c +++ b/cups/auth.c @@ -454,7 +454,7 @@ _cupsSetNegotiateAuthString( authsize = sizeof(http->_authstring); } - strlcpy(http->authstring, "Negotiate ", authsize); + strlcpy(http->authstring, "Negotiate ", (size_t)authsize); httpEncode64_2(http->authstring + 10, authsize - 10, output_token.value, (int)output_token.length); diff --git a/cups/dest.c b/cups/dest.c index 92ce8acd2..f9853c8cd 100644 --- a/cups/dest.c +++ b/cups/dest.c @@ -3094,7 +3094,7 @@ cups_dnssd_query_cb( txt ++; if (txt < txtnext) - memcpy(value, txt, txtnext - txt); + memcpy(value, txt, (size_t)(txtnext - txt)); value[txtnext - txt] = '\0'; DEBUG_printf(("6cups_dnssd_query_cb: %s=%s", key, value)); @@ -3773,22 +3773,21 @@ cups_make_string( { case IPP_TAG_INTEGER : case IPP_TAG_ENUM : - snprintf(ptr, end - ptr + 1, "%d", attr->values[i].integer); + snprintf(ptr, (size_t)(end - ptr + 1), "%d", attr->values[i].integer); break; case IPP_TAG_BOOLEAN : if (attr->values[i].boolean) - strlcpy(ptr, "true", end - ptr + 1); + strlcpy(ptr, "true", (size_t)(end - ptr + 1)); else - strlcpy(ptr, "false", end - ptr + 1); + strlcpy(ptr, "false", (size_t)(end - ptr + 1)); break; case IPP_TAG_RANGE : if (attr->values[i].range.lower == attr->values[i].range.upper) - snprintf(ptr, end - ptr + 1, "%d", attr->values[i].range.lower); + snprintf(ptr, (size_t)(end - ptr + 1), "%d", attr->values[i].range.lower); else - snprintf(ptr, end - ptr + 1, "%d-%d", attr->values[i].range.lower, - attr->values[i].range.upper); + snprintf(ptr, (size_t)(end - ptr + 1), "%d-%d", attr->values[i].range.lower, attr->values[i].range.upper); break; default : diff --git a/cups/emit.c b/cups/emit.c index 759e634c0..5efbb176f 100644 --- a/cups/emit.c +++ b/cups/emit.c @@ -814,8 +814,7 @@ ppdEmitString(ppd_file_t *ppd, /* I - PPD file record */ break; case PPD_CUSTOM_INT : - snprintf(bufptr, bufend - bufptr, "%d", - cparam->current.custom_int); + snprintf(bufptr, (size_t)(bufend - bufptr), "%d", cparam->current.custom_int); bufptr += strlen(bufptr); break; @@ -824,8 +823,7 @@ ppdEmitString(ppd_file_t *ppd, /* I - PPD file record */ case PPD_CUSTOM_STRING : if (cparam->current.custom_string) { - strlcpy(bufptr, cparam->current.custom_string, - bufend - bufptr); + strlcpy(bufptr, cparam->current.custom_string, (size_t)(bufend - bufptr)); bufptr += strlen(bufptr); } break; @@ -845,7 +843,7 @@ ppdEmitString(ppd_file_t *ppd, /* I - PPD file record */ * Otherwise just copy the option code directly... */ - strlcpy(bufptr, choices[i]->code, bufend - bufptr + 1); + strlcpy(bufptr, choices[i]->code, (size_t)(bufend - bufptr + 1)); bufptr += strlen(bufptr); } } @@ -856,7 +854,7 @@ ppdEmitString(ppd_file_t *ppd, /* I - PPD file record */ * options... */ - strlcpy(bufptr, "[{\n", bufend - bufptr + 1); + strlcpy(bufptr, "[{\n", (size_t)(bufend - bufptr + 1)); bufptr += 3; /* @@ -881,8 +879,7 @@ ppdEmitString(ppd_file_t *ppd, /* I - PPD file record */ float values[5]; /* Values for custom command */ - strlcpy(bufptr, "%%BeginFeature: *CustomPageSize True\n", - bufend - bufptr + 1); + strlcpy(bufptr, "%%BeginFeature: *CustomPageSize True\n", (size_t)(bufend - bufptr + 1)); bufptr += 37; size = ppdPageSize(ppd, "Custom"); @@ -977,7 +974,7 @@ ppdEmitString(ppd_file_t *ppd, /* I - PPD file record */ * Level 2 command sequence... */ - strlcpy(bufptr, ppd_custom_code, bufend - bufptr + 1); + strlcpy(bufptr, ppd_custom_code, (size_t)(bufend - bufptr + 1)); bufptr += strlen(bufptr); } } @@ -1000,8 +997,7 @@ ppdEmitString(ppd_file_t *ppd, /* I - PPD file record */ cparam = (ppd_cparam_t *)cupsArrayNext(coption->params)) cupsArrayAdd(params, cparam); - snprintf(bufptr, bufend - bufptr + 1, - "%%%%BeginFeature: *Custom%s True\n", coption->keyword); + snprintf(bufptr, (size_t)(bufend - bufptr + 1), "%%%%BeginFeature: *Custom%s True\n", coption->keyword); bufptr += strlen(bufptr); for (cparam = (ppd_cparam_t *)cupsArrayFirst(params); @@ -1020,8 +1016,7 @@ ppdEmitString(ppd_file_t *ppd, /* I - PPD file record */ break; case PPD_CUSTOM_INT : - snprintf(bufptr, bufend - bufptr + 1, "%d\n", - cparam->current.custom_int); + snprintf(bufptr, (size_t)(bufend - bufptr + 1), "%d\n", cparam->current.custom_int); bufptr += strlen(bufptr); break; @@ -1036,7 +1031,7 @@ ppdEmitString(ppd_file_t *ppd, /* I - PPD file record */ { if (*s < ' ' || *s == '(' || *s == ')' || *s >= 127) { - snprintf(bufptr, bufend - bufptr + 1, "\\%03o", *s & 255); + snprintf(bufptr, (size_t)(bufend - bufptr + 1), "\\%03o", *s & 255); bufptr += strlen(bufptr); } else @@ -1054,15 +1049,14 @@ ppdEmitString(ppd_file_t *ppd, /* I - PPD file record */ } else { - snprintf(bufptr, bufend - bufptr + 1, "%%%%BeginFeature: *%s %s\n", - choices[i]->option->keyword, choices[i]->choice); + snprintf(bufptr, (size_t)(bufend - bufptr + 1), "%%%%BeginFeature: *%s %s\n", choices[i]->option->keyword, choices[i]->choice); bufptr += strlen(bufptr); } if (choices[i]->code && choices[i]->code[0]) { j = (int)strlen(choices[i]->code); - memcpy(bufptr, choices[i]->code, j); + memcpy(bufptr, choices[i]->code, (size_t)j); bufptr += j; if (choices[i]->code[j - 1] != '\n') @@ -1070,7 +1064,7 @@ ppdEmitString(ppd_file_t *ppd, /* I - PPD file record */ } strlcpy(bufptr, "%%EndFeature\n" - "} stopped cleartomark\n", bufend - bufptr + 1); + "} stopped cleartomark\n", (size_t)(bufend - bufptr + 1)); bufptr += strlen(bufptr); DEBUG_printf(("2ppdEmitString: Offset in string is %d...", @@ -1078,7 +1072,7 @@ ppdEmitString(ppd_file_t *ppd, /* I - PPD file record */ } else { - strlcpy(bufptr, choices[i]->code, bufend - bufptr + 1); + strlcpy(bufptr, choices[i]->code, (size_t)(bufend - bufptr + 1)); bufptr += strlen(bufptr); } diff --git a/cups/file.c b/cups/file.c index 5bec683f3..337641952 100644 --- a/cups/file.c +++ b/cups/file.c @@ -508,7 +508,7 @@ cupsFileFind(const char *filename, /* I - File to find */ if (!access(filename, 0)) { - strlcpy(buffer, filename, bufsize); + strlcpy(buffer, filename, (size_t)bufsize); return (buffer); } else @@ -533,7 +533,7 @@ cupsFileFind(const char *filename, /* I - File to find */ if (bufptr > buffer && bufptr[-1] != '/' && bufptr < bufend) *bufptr++ = '/'; - strlcpy(bufptr, filename, bufend - bufptr); + strlcpy(bufptr, filename, (size_t)(bufend - bufptr)); #ifdef WIN32 if (!access(buffer, 0)) @@ -560,7 +560,7 @@ cupsFileFind(const char *filename, /* I - File to find */ if (bufptr > buffer && bufptr[-1] != '/' && bufptr < bufend) *bufptr++ = '/'; - strlcpy(bufptr, filename, bufend - bufptr); + strlcpy(bufptr, filename, (size_t)(bufend - bufptr)); if (!access(buffer, 0)) { @@ -1382,7 +1382,7 @@ cupsFilePrintf(cups_file_t *fp, /* I - CUPS file */ } else { - memcpy(fp->ptr, fp->printf_buffer, bytes); + memcpy(fp->ptr, fp->printf_buffer, (size_t)bytes); fp->ptr += bytes; return ((int)bytes); } @@ -1561,7 +1561,7 @@ cupsFilePuts(cups_file_t *fp, /* I - CUPS file */ } else { - memcpy(fp->ptr, s, bytes); + memcpy(fp->ptr, s, (size_t)bytes); fp->ptr += bytes; return ((int)bytes); } @@ -1619,7 +1619,7 @@ cupsFileRead(cups_file_t *fp, /* I - CUPS file */ if (count > (ssize_t)bytes) count = (ssize_t)bytes; - memcpy(buf, fp->ptr, count); + memcpy(buf, fp->ptr,(size_t) count); fp->ptr += count; fp->pos += count; @@ -2312,7 +2312,7 @@ cups_fill(cups_file_t *fp) /* I - CUPS file */ */ if ((bytes = end - ptr) > 0) - memcpy(fp->cbuf, ptr, bytes); + memcpy(fp->cbuf, ptr, (size_t)bytes); /* * Setup the decompressor data... diff --git a/cups/http-addr.c b/cups/http-addr.c index a3a628c54..0a49ee3e8 100644 --- a/cups/http-addr.c +++ b/cups/http-addr.c @@ -341,7 +341,7 @@ httpAddrLookup( #ifdef AF_LOCAL if (addr->addr.sa_family == AF_LOCAL) { - strlcpy(name, addr->un.sun_path, namelen); + strlcpy(name, addr->un.sun_path, (size_t)namelen); return (name); } #endif /* AF_LOCAL */ @@ -352,7 +352,7 @@ httpAddrLookup( if (httpAddrLocalhost(addr)) { - strlcpy(name, "localhost", namelen); + strlcpy(name, "localhost", (size_t)namelen); return (name); } @@ -423,7 +423,7 @@ httpAddrLookup( return (httpAddrString(addr, name, namelen)); } - strlcpy(name, host->h_name, namelen); + strlcpy(name, host->h_name, (size_t)namelen); } #endif /* HAVE_GETNAMEINFO */ @@ -519,9 +519,9 @@ httpAddrString(const http_addr_t *addr, /* I - Address to convert */ if (addr->addr.sa_family == AF_LOCAL) { if (addr->un.sun_path[0] == '/') - strlcpy(s, addr->un.sun_path, slen); + strlcpy(s, addr->un.sun_path, (size_t)slen); else - strlcpy(s, "localhost", slen); + strlcpy(s, "localhost", (size_t)slen); } else #endif /* AF_LOCAL */ @@ -529,10 +529,9 @@ httpAddrString(const http_addr_t *addr, /* I - Address to convert */ { unsigned temp; /* Temporary address */ - temp = ntohl(addr->ipv4.sin_addr.s_addr); - snprintf(s, slen, "%d.%d.%d.%d", (temp >> 24) & 255, + snprintf(s, (size_t)slen, "%d.%d.%d.%d", (temp >> 24) & 255, (temp >> 16) & 255, (temp >> 8) & 255, temp & 255); } #ifdef AF_INET6 @@ -573,8 +572,7 @@ httpAddrString(const http_addr_t *addr, /* I - Address to convert */ { temp = ntohl(addr->ipv6.sin6_addr.s6_addr32[i]); - snprintf(sptr, sizeof(temps) - (sptr - temps), "%s%x", prefix, - (temp >> 16) & 0xffff); + snprintf(sptr, sizeof(temps) - (size_t)(sptr - temps), "%s%x", prefix, (temp >> 16) & 0xffff); prefix = ":"; sptr += strlen(sptr); @@ -582,7 +580,7 @@ httpAddrString(const http_addr_t *addr, /* I - Address to convert */ if (temp || i == 3 || addr->ipv6.sin6_addr.s6_addr32[i + 1]) { - snprintf(sptr, sizeof(temps) - (sptr - temps), "%s%x", prefix, temp); + snprintf(sptr, sizeof(temps) - (size_t)(sptr - temps), "%s%x", prefix, temp); sptr += strlen(sptr); } } @@ -594,7 +592,7 @@ httpAddrString(const http_addr_t *addr, /* I - Address to convert */ if (i < 4) { - snprintf(sptr, sizeof(temps) - (sptr - temps), "%s:", prefix); + snprintf(sptr, sizeof(temps) - (size_t)(sptr - temps), "%s:", prefix); prefix = ":"; sptr += strlen(sptr); @@ -605,13 +603,11 @@ httpAddrString(const http_addr_t *addr, /* I - Address to convert */ if ((temp & 0xffff0000) || (i > 0 && addr->ipv6.sin6_addr.s6_addr32[i - 1])) { - snprintf(sptr, sizeof(temps) - (sptr - temps), "%s%x", prefix, - (temp >> 16) & 0xffff); + snprintf(sptr, sizeof(temps) - (size_t)(sptr - temps), "%s%x", prefix, (temp >> 16) & 0xffff); sptr += strlen(sptr); } - snprintf(sptr, sizeof(temps) - (sptr - temps), "%s%x", prefix, - temp & 0xffff); + snprintf(sptr, sizeof(temps) - (size_t)(sptr - temps), "%s%x", prefix, temp & 0xffff); sptr += strlen(sptr); } } @@ -629,7 +625,7 @@ httpAddrString(const http_addr_t *addr, /* I - Address to convert */ * Empty at end... */ - strlcpy(sptr, "::", sizeof(temps) - (sptr - temps)); + strlcpy(sptr, "::", sizeof(temps) - (size_t)(sptr - temps)); } } # endif /* HAVE_GETNAMEINFO */ @@ -638,11 +634,11 @@ httpAddrString(const http_addr_t *addr, /* I - Address to convert */ * Add "[v1." and "]" around IPv6 address to convert to URI form. */ - snprintf(s, slen, "[v1.%s]", temps); + snprintf(s, (size_t)slen, "[v1.%s]", temps); } #endif /* AF_INET6 */ else - strlcpy(s, "UNKNOWN", slen); + strlcpy(s, "UNKNOWN", (size_t)slen); DEBUG_printf(("1httpAddrString: returning \"%s\"...", s)); @@ -804,9 +800,9 @@ httpGetHostname(http_t *http, /* I - HTTP connection or NULL */ return (http->hostname); } else if (http->hostname[0] == '/') - strlcpy(s, "localhost", slen); + strlcpy(s, "localhost", (size_t)slen); else - strlcpy(s, http->hostname, slen); + strlcpy(s, http->hostname, (size_t)slen); } else { @@ -818,7 +814,7 @@ httpGetHostname(http_t *http, /* I - HTTP connection or NULL */ return (NULL); if (gethostname(s, (size_t)slen) < 0) - strlcpy(s, "localhost", slen); + strlcpy(s, "localhost", (size_t)slen); if (!strchr(s, '.')) { @@ -842,7 +838,7 @@ httpGetHostname(http_t *http, /* I - HTTP connection or NULL */ * Append ".local." to the hostname we get... */ - snprintf(s, slen, "%s.local.", localStr); + snprintf(s, (size_t)slen, "%s.local.", localStr); } if (local) @@ -863,7 +859,7 @@ httpGetHostname(http_t *http, /* I - HTTP connection or NULL */ * Use the resolved hostname... */ - strlcpy(s, host->h_name, slen); + strlcpy(s, host->h_name, (size_t)slen); } #endif /* HAVE_SCDYNAMICSTORECOPYCOMPUTERNAME */ } diff --git a/cups/http-support.c b/cups/http-support.c index c1353514f..501b2a2ac 100644 --- a/cups/http-support.c +++ b/cups/http-support.c @@ -358,7 +358,7 @@ httpAssembleURI( if (port > 0) { - snprintf(ptr, end - ptr + 1, ":%d", port); + snprintf(ptr, (size_t)(end - ptr + 1), ":%d", port); ptr += strlen(ptr); if (ptr >= end) @@ -809,10 +809,7 @@ httpGetDateString2(time_t t, /* I - UNIX time */ tdate = gmtime(&t); if (tdate) - snprintf(s, slen, "%s, %02d %s %d %02d:%02d:%02d GMT", - http_days[tdate->tm_wday], tdate->tm_mday, - http_months[tdate->tm_mon], tdate->tm_year + 1900, - tdate->tm_hour, tdate->tm_min, tdate->tm_sec); + snprintf(s, (size_t)slen, "%s, %02d %s %d %02d:%02d:%02d GMT", http_days[tdate->tm_wday], tdate->tm_mday, http_months[tdate->tm_mon], tdate->tm_year + 1900, tdate->tm_hour, tdate->tm_min, tdate->tm_sec); else s[0] = '\0'; @@ -1007,7 +1004,7 @@ httpSeparateURI( * Workaround for HP IPP client bug... */ - strlcpy(scheme, "ipp", schemelen); + strlcpy(scheme, "ipp", (size_t)schemelen); status = HTTP_URI_STATUS_MISSING_SCHEME; } else if (*uri == '/') @@ -1016,7 +1013,7 @@ httpSeparateURI( * Filename... */ - strlcpy(scheme, "file", schemelen); + strlcpy(scheme, "file", (size_t)schemelen); status = HTTP_URI_STATUS_MISSING_SCHEME; } else @@ -2473,9 +2470,7 @@ http_resolve_cb( { for (addr = addrlist; addr; addr = addr->next) { - int error = getnameinfo(&(addr->addr.addr), - httpAddrLength(&(addr->addr)), - fqdn, sizeof(fqdn), NULL, 0, NI_NAMEREQD); + int error = getnameinfo(&(addr->addr.addr), (socklen_t)httpAddrLength(&(addr->addr)), fqdn, sizeof(fqdn), NULL, 0, NI_NAMEREQD); if (!error) { diff --git a/cups/http.c b/cups/http.c index 8a4236e0d..18ca6fbc5 100644 --- a/cups/http.c +++ b/cups/http.c @@ -1315,7 +1315,7 @@ httpGets(char *line, /* I - Line to read into */ http->used -= (int)(bufptr - http->buffer); if (http->used > 0) - memmove(http->buffer, bufptr, http->used); + memmove(http->buffer, bufptr, (size_t)http->used); if (eol) { @@ -1809,7 +1809,7 @@ httpPeek(http_t *http, /* I - HTTP connection */ http->data_remaining -= buflen; if (http->used > 0) - memmove(http->buffer, http->buffer + buflen, http->used); + memmove(http->buffer, http->buffer + buflen, (size_t)http->used); } DEBUG_printf(("2httpPeek: length=%d, avail_in=%d", (int)length, @@ -4141,11 +4141,11 @@ http_read_buffered(http_t *http, /* I - HTTP connection */ DEBUG_printf(("2http_read: Grabbing %d bytes from input buffer.", (int)bytes)); - memcpy(buffer, http->buffer, bytes); + memcpy(buffer, http->buffer, (size_t)bytes); http->used -= (int)bytes; if (http->used > 0) - memmove(http->buffer, http->buffer + bytes, http->used); + memmove(http->buffer, http->buffer + bytes, (size_t)http->used); } else bytes = http_read(http, buffer, length); diff --git a/cups/ipp-support.c b/cups/ipp-support.c index 29ea8b14c..a5c233e20 100644 --- a/cups/ipp-support.c +++ b/cups/ipp-support.c @@ -638,46 +638,37 @@ ippAttributeString( ptr = ippEnumString(attr->name, val->integer); if (buffer && bufptr < bufend) - strlcpy(bufptr, ptr, bufend - bufptr + 1); + strlcpy(bufptr, ptr, (size_t)(bufend - bufptr + 1)); bufptr += strlen(ptr); break; case IPP_TAG_INTEGER : if (buffer && bufptr < bufend) - bufptr += snprintf(bufptr, bufend - bufptr + 1, "%d", val->integer); + bufptr += snprintf(bufptr, (size_t)(bufend - bufptr + 1), "%d", val->integer); else bufptr += snprintf(temp, sizeof(temp), "%d", val->integer); break; case IPP_TAG_BOOLEAN : if (buffer && bufptr < bufend) - strlcpy(bufptr, val->boolean ? "true" : "false", - bufend - bufptr + 1); + strlcpy(bufptr, val->boolean ? "true" : "false", (size_t)(bufend - bufptr + 1)); bufptr += val->boolean ? 4 : 5; break; case IPP_TAG_RANGE : if (buffer && bufptr < bufend) - bufptr += snprintf(bufptr, bufend - bufptr + 1, "%d-%d", - val->range.lower, val->range.upper); + bufptr += snprintf(bufptr, (size_t)(bufend - bufptr + 1), "%d-%d", val->range.lower, val->range.upper); else - bufptr += snprintf(temp, sizeof(temp), "%d-%d", val->range.lower, - val->range.upper); + bufptr += snprintf(temp, sizeof(temp), "%d-%d", val->range.lower, val->range.upper); break; case IPP_TAG_RESOLUTION : if (buffer && bufptr < bufend) - bufptr += snprintf(bufptr, bufend - bufptr + 1, "%dx%d%s", - val->resolution.xres, val->resolution.yres, - val->resolution.units == IPP_RES_PER_INCH ? - "dpi" : "dpcm"); + bufptr += snprintf(bufptr, (size_t)(bufend - bufptr + 1), "%dx%d%s", val->resolution.xres, val->resolution.yres, val->resolution.units == IPP_RES_PER_INCH ? "dpi" : "dpcm"); else - bufptr += snprintf(temp, sizeof(temp), "%dx%d%s", - val->resolution.xres, val->resolution.yres, - val->resolution.units == IPP_RES_PER_INCH ? - "dpi" : "dpcm"); + bufptr += snprintf(temp, sizeof(temp), "%dx%d%s", val->resolution.xres, val->resolution.yres, val->resolution.units == IPP_RES_PER_INCH ? "dpi" : "dpcm"); break; case IPP_TAG_DATE : @@ -698,7 +689,7 @@ ippAttributeString( val->date[10]); if (buffer && bufptr < bufend) - strlcpy(bufptr, temp, bufend - bufptr + 1); + strlcpy(bufptr, temp, (size_t)(bufend - bufptr + 1)); bufptr += strlen(temp); } @@ -742,7 +733,7 @@ ippAttributeString( bufptr ++; if (buffer && bufptr < bufend) - strlcpy(bufptr, val->string.language, bufend - bufptr); + strlcpy(bufptr, val->string.language, (size_t)(bufend - bufptr)); bufptr += strlen(val->string.language); if (buffer && bufptr < bufend) @@ -775,11 +766,9 @@ ippAttributeString( else if (!isprint(*ptr & 255)) { if (buffer && bufptr < bufend) - bufptr += snprintf(bufptr, bufend - bufptr + 1, "\\%03o", - *ptr & 255); + bufptr += snprintf(bufptr, (size_t)(bufend - bufptr + 1), "\\%03o", *ptr & 255); else - bufptr += snprintf(temp, sizeof(temp), "\\%03o", - *ptr & 255); + bufptr += snprintf(temp, sizeof(temp), "\\%03o", *ptr & 255); } else { @@ -793,7 +782,7 @@ ippAttributeString( default : ptr = ippTagString(attr->value_tag); if (buffer && bufptr < bufend) - strlcpy(bufptr, ptr, bufend - bufptr + 1); + strlcpy(bufptr, ptr, (size_t)(bufend - bufptr + 1)); bufptr += strlen(ptr); break; } @@ -2231,7 +2220,7 @@ ipp_col_string(ipp_t *col, /* I - Collection attribute */ prefix = ' '; if (buffer && bufptr < bufend) - bufptr += snprintf(bufptr, bufend - bufptr + 1, "%s=", attr->name); + bufptr += snprintf(bufptr, (size_t)(bufend - bufptr + 1), "%s=", attr->name); else bufptr += strlen(attr->name) + 1; diff --git a/cups/ipp.c b/cups/ipp.c index dafbf9e7b..e83bfd4de 100644 --- a/cups/ipp.c +++ b/cups/ipp.c @@ -556,7 +556,7 @@ ippAddOctetString(ipp_t *ipp, /* I - IPP message */ return (NULL); } - memcpy(attr->values[0].unknown.data, data, datalen); + memcpy(attr->values[0].unknown.data, data, (size_t)datalen); } /* @@ -1715,7 +1715,7 @@ ippCopyAttribute( if ((dstval->unknown.data = malloc((size_t)dstval->unknown.length)) == NULL) dstval->unknown.length = 0; else - memcpy(dstval->unknown.data, srcval->unknown.data, dstval->unknown.length); + memcpy(dstval->unknown.data, srcval->unknown.data, (size_t)dstval->unknown.length); } } break; /* anti-compiler-warning-code */ @@ -3472,7 +3472,7 @@ ippReadIO(void *src, /* I - Data source */ return (IPP_STATE_ERROR); } - memcpy(string, bufptr + 2, n); + memcpy(string, bufptr + 2, (size_t)n); string[n] = '\0'; value->string.language = _cupsStrAlloc((char *)string); @@ -3967,7 +3967,7 @@ ippSetOctetString( if ((temp = malloc((size_t)datalen)) != NULL) { - memcpy(temp, data, datalen); + memcpy(temp, data, (size_t)datalen); value->unknown.data = temp; value->unknown.length = datalen; @@ -5575,7 +5575,7 @@ ippWriteIO(void *dst, /* I - Destination */ *bufptr++ = (ipp_uchar_t)(n >> 8); *bufptr++ = (ipp_uchar_t)n; - memcpy(bufptr, attr->name, n); + memcpy(bufptr, attr->name, (size_t)n); bufptr += n; } else @@ -5610,7 +5610,7 @@ ippWriteIO(void *dst, /* I - Destination */ *bufptr++ = 0; *bufptr++ = (ipp_uchar_t)(n >> 8); *bufptr++ = (ipp_uchar_t)n; - memcpy(bufptr, attr->name, n); + memcpy(bufptr, attr->name, (size_t)n); bufptr += n; if (attr->value_tag > 0xff) @@ -5819,7 +5819,7 @@ ippWriteIO(void *dst, /* I - Destination */ if (n > 0) { - memcpy(bufptr, value->string.text, n); + memcpy(bufptr, value->string.text, (size_t)n); bufptr += n; } } @@ -6060,7 +6060,7 @@ ippWriteIO(void *dst, /* I - Destination */ /* Language */ if (n > 0) { - memcpy(bufptr, value->string.language, n); + memcpy(bufptr, value->string.language, (size_t)n); bufptr += n; } @@ -6076,7 +6076,7 @@ ippWriteIO(void *dst, /* I - Destination */ /* Text */ if (n > 0) { - memcpy(bufptr, value->string.text, n); + memcpy(bufptr, value->string.text, (size_t)n); bufptr += n; } } @@ -6219,7 +6219,7 @@ ippWriteIO(void *dst, /* I - Destination */ /* Value */ if (n > 0) { - memcpy(bufptr, value->unknown.data, n); + memcpy(bufptr, value->unknown.data, (size_t)n); bufptr += n; } } diff --git a/cups/localize.c b/cups/localize.c index 4c702acdf..56a8b724f 100644 --- a/cups/localize.c +++ b/cups/localize.c @@ -36,7 +36,7 @@ * Local functions... */ -static cups_lang_t *ppd_ll_CC(char *ll_CC, int ll_CC_size); +static cups_lang_t *ppd_ll_CC(char *ll_CC, size_t ll_CC_size); /* @@ -712,8 +712,8 @@ _ppdLocalizedAttr(ppd_file_t *ppd, /* I - PPD file */ */ static cups_lang_t * /* O - Current language */ -ppd_ll_CC(char *ll_CC, /* O - Country-specific locale name */ - int ll_CC_size) /* I - Size of country-specific name */ +ppd_ll_CC(char *ll_CC, /* O - Country-specific locale name */ + size_t ll_CC_size) /* I - Size of country-specific name */ { cups_lang_t *lang; /* Current language */ diff --git a/cups/md5.c b/cups/md5.c index 0e1eaaafa..c2d627bd9 100644 --- a/cups/md5.c +++ b/cups/md5.c @@ -300,7 +300,7 @@ _cupsMD5Append(_cups_md5_state_t *pms, const unsigned char *data, int nbytes) if (offset) { int copy = (offset + nbytes > 64 ? 64 - offset : nbytes); - memcpy(pms->buf + offset, p, copy); + memcpy(pms->buf + offset, p, (size_t)copy); if (offset + copy < 64) return; p += copy; @@ -314,7 +314,7 @@ _cupsMD5Append(_cups_md5_state_t *pms, const unsigned char *data, int nbytes) /* Process a final partial block. */ if (left) - memcpy(pms->buf, p, left); + memcpy(pms->buf, p, (size_t)left); } void diff --git a/cups/ppd-cache.c b/cups/ppd-cache.c index 64e9d3a6e..5c1a90159 100644 --- a/cups/ppd-cache.c +++ b/cups/ppd-cache.c @@ -2612,7 +2612,7 @@ _pwgPageSizeForMedia( * Copy the size name from class_sizename_dimensions... */ - memcpy(name, sizeptr + 1, dimptr - sizeptr - 1); + memcpy(name, sizeptr + 1, (size_t)(dimptr - sizeptr - 1)); name[dimptr - sizeptr - 1] = '\0'; } diff --git a/cups/sidechannel.c b/cups/sidechannel.c index d7638372d..0928d8b34 100644 --- a/cups/sidechannel.c +++ b/cups/sidechannel.c @@ -264,7 +264,7 @@ cupsSideChannelRead( *status = (cups_sc_status_t)buffer[1]; *datalen = templen; - memcpy(data, buffer + 4, templen); + memcpy(data, buffer + 4, (size_t)templen); } _cupsBufferRelease(buffer); @@ -364,7 +364,7 @@ cupsSideChannelSNMPGet( return (CUPS_SC_STATUS_TOO_BIG); } - memcpy(data, real_data + real_oidlen, real_datalen); + memcpy(data, real_data + real_oidlen, (size_t)real_datalen); data[real_datalen] = '\0'; *datalen = real_datalen; @@ -607,7 +607,7 @@ cupsSideChannelWrite( if (datalen > 0) { - memcpy(buffer + 4, data, datalen); + memcpy(buffer + 4, data, (size_t)datalen); bytes += datalen; } diff --git a/cups/snmp.c b/cups/snmp.c index a291e8a82..4c62f959f 100644 --- a/cups/snmp.c +++ b/cups/snmp.c @@ -280,7 +280,7 @@ _cupsSNMPOIDToString(const int *src, /* I - OID */ for (dstptr = dst, dstend = dstptr + dstsize - 1; *src >= 0 && dstptr < dstend; src ++, dstptr += strlen(dstptr)) - snprintf(dstptr, dstend - dstptr + 1, ".%d", *src); + snprintf(dstptr, (size_t)(dstend - dstptr + 1), ".%d", *src); if (*src >= 0) return (NULL); diff --git a/cups/string.c b/cups/string.c index 0bc0690c5..ce5d9e987 100644 --- a/cups/string.c +++ b/cups/string.c @@ -243,7 +243,7 @@ _cupsStrFormatd(char *buf, /* I - String */ } else { - strlcpy(buf, temp, bufend - buf + 1); + strlcpy(buf, temp, (size_t)(bufend - buf + 1)); bufptr = buf + strlen(buf); } diff --git a/cups/tempfile.c b/cups/tempfile.c index 75c95d6fb..d5703bb2f 100644 --- a/cups/tempfile.c +++ b/cups/tempfile.c @@ -1,24 +1,18 @@ /* * "$Id$" * - * Temp file utilities for CUPS. + * Temp file utilities for CUPS. * - * Copyright 2007-2012 by Apple Inc. - * Copyright 1997-2006 by Easy Software Products. + * Copyright 2007-2014 by Apple Inc. + * Copyright 1997-2006 by Easy Software Products. * - * 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/". * - * This file is subject to the Apple OS-Developed Software exception. - * - * Contents: - * - * cupsTempFd() - Creates a temporary file. - * cupsTempFile() - Generates a temporary filename. - * cupsTempFile2() - Creates a temporary CUPS file. + * This file is subject to the Apple OS-Developed Software exception. */ /* @@ -103,8 +97,7 @@ cupsTempFd(char *filename, /* I - Pointer to buffer */ * Format a string using the hex time values... */ - snprintf(filename, len - 1, "%s/%05lx%08lx", tmpdir, - GetCurrentProcessId(), curtime); + snprintf(filename, (size_t)len - 1, "%s/%05lx%08lx", tmpdir, GetCurrentProcessId(), curtime); #else /* * Get the current time of day... @@ -116,8 +109,7 @@ cupsTempFd(char *filename, /* I - Pointer to buffer */ * Format a string using the hex time values... */ - snprintf(filename, len - 1, "%s/%05x%08x", tmpdir, (unsigned)getpid(), - (unsigned)(curtime.tv_sec + curtime.tv_usec + tries)); + snprintf(filename, (size_t)len - 1, "%s/%05x%08x", tmpdir, (unsigned)getpid(), (unsigned)(curtime.tv_sec + curtime.tv_usec + tries)); #endif /* WIN32 */ /* diff --git a/cups/testppd.c b/cups/testppd.c index dd94b003f..9c0616e69 100644 --- a/cups/testppd.c +++ b/cups/testppd.c @@ -28,6 +28,7 @@ # include # include #endif /* WIN32 */ +#include /* diff --git a/cups/tls-gnutls.c b/cups/tls-gnutls.c index 0f5b11881..f698a87e5 100644 --- a/cups/tls-gnutls.c +++ b/cups/tls-gnutls.c @@ -16,6 +16,20 @@ */ +/* + * Local globals... + */ + +static int tls_auto_create = 0; + /* Auto-create self-signed certs? */ +static char *tls_common_name = NULL; + /* Default common name */ +static char *tls_keypath = NULL; + /* Server cert keychain path */ +static _cups_mutex_t tls_mutex = _CUPS_MUTEX_INITIALIZER; + /* Mutex for keychain/certs */ + + /* * Local functions... */ @@ -25,6 +39,71 @@ static ssize_t http_gnutls_read(gnutls_transport_ptr_t ptr, void *data, size_t l static ssize_t http_gnutls_write(gnutls_transport_ptr_t ptr, const void *data, size_t length); +/* + * 'cupsMakeServerCredentials()' - Make a self-signed certificate and private key pair. + * + * @since CUPS 2.0@ + */ + +int /* O - 1 on success, 0 on failure */ +cupsMakeServerCredentials( + const char *path, /* I - Path to keychain/directory */ + const char *common_name, /* I - Common name */ + int num_alt_names, /* I - Number of subject alternate names */ + const char **alt_names, /* I - Subject Alternate Names */ + time_t expiration_date) /* I - Expiration date */ +{ + (void)path; + (void)common_name; + (void)num_alt_names; + (void)alt_names; + (void)expiration_date; + + return (0); +} + + +/* + * 'cupsSetServerCredentials()' - Set the default server credentials. + * + * Note: The server credentials are used by all threads in the running process. + * This function is threadsafe. + * + * @since CUPS 2.0@ + */ + +int /* O - 1 on success, 0 on failure */ +cupsSetServerCredentials( + const char *path, /* I - Path to keychain/directory */ + const char *common_name, /* I - Default common name for server */ + int auto_create) /* I - 1 = automatically create self-signed certificates */ +{ + _cupsMutexLock(&tls_mutex); + + /* + * Free old values... + */ + + if (tls_keypath) + _cupsStrFree(tls_keypath); + + if (tls_common_name) + _cupsStrFree(tls_common_name); + + /* + * Save the new values... + */ + + tls_keypath = _cupsStrAlloc(path); + tls_auto_create = auto_create; + tls_common_name = _cupsStrAlloc(common_name); + + _cupsMutexUnlock(&tls_mutex); + + return (1); +} + + /* * 'httpCopyCredentials()' - Copy the credentials associated with the peer in * an encrypted connection. @@ -177,7 +256,7 @@ http_tls_read(http_t *http, /* I - Connection to server */ ssize_t result; /* Return value */ - result = gnutls_record_recv(http->tls, buf, len); + result = gnutls_record_recv(http->tls, buf, (size_t)len); if (result < 0 && !errno) { @@ -343,7 +422,7 @@ http_tls_write(http_t *http, /* I - Connection to server */ DEBUG_printf(("2http_write_ssl(http=%p, buf=%p, len=%d)", http, buf, len)); - result = gnutls_record_send(http->tls, buf, len); + result = gnutls_record_send(http->tls, buf, (size_t)len); if (result < 0 && !errno) { diff --git a/cups/transcode.c b/cups/transcode.c index 8245aa3ea..58fab4ba7 100644 --- a/cups/transcode.c +++ b/cups/transcode.c @@ -109,7 +109,7 @@ cupsCharsetToUTF8( if (encoding == CUPS_UTF8 || encoding <= CUPS_US_ASCII || encoding >= CUPS_ENCODING_VBCS_END) { - strlcpy((char *)dest, src, maxout); + strlcpy((char *)dest, src, (size_t)maxout); return ((int)strlen((char *)dest)); } @@ -226,7 +226,7 @@ cupsUTF8ToCharset( if (encoding == CUPS_UTF8 || encoding >= CUPS_ENCODING_VBCS_END) { - strlcpy(dest, (char *)src, maxout); + strlcpy(dest, (char *)src, (size_t)maxout); return ((int)strlen(dest)); } diff --git a/cups/util.c b/cups/util.c index 0b6c289a4..110142b65 100644 --- a/cups/util.c +++ b/cups/util.c @@ -1670,7 +1670,7 @@ cups_get_printer_uri( * Do the request and get back a response... */ - snprintf(resource, resourcesize, "/printers/%s", name); + snprintf(resource, (size_t)resourcesize, "/printers/%s", name); if ((response = cupsDoRequest(http, request, resource)) != NULL) { diff --git a/filter/raster.c b/filter/raster.c index d9658d710..d1387086d 100644 --- a/filter/raster.c +++ b/filter/raster.c @@ -474,7 +474,7 @@ cupsRasterReadPixels(cups_raster_t *r, /* I - Raster stream */ */ if (ptr != p) - memcpy(p, ptr, bytes); + memcpy(p, ptr, (size_t)bytes); } else { @@ -485,7 +485,7 @@ cupsRasterReadPixels(cups_raster_t *r, /* I - Raster stream */ if ((unsigned)(bytes = (int)(r->pend - r->pcurrent)) > remaining) bytes = (ssize_t)remaining; - memcpy(p, r->pcurrent, bytes); + memcpy(p, r->pcurrent, (size_t)bytes); r->pcurrent += bytes; if (r->pcurrent >= r->pend) @@ -868,7 +868,7 @@ cupsRasterWritePixels(cups_raster_t *r, /* I - Raster stream */ * Copy the raster data to the buffer... */ - memcpy(r->pcurrent, p, bytes); + memcpy(r->pcurrent, p, (size_t)bytes); r->pcurrent += bytes; @@ -1125,7 +1125,7 @@ cups_raster_read(cups_raster_t *r, /* I - Raster stream */ * Use memcpy() for a large read... */ - memcpy(buf, r->bufptr, count); + memcpy(buf, r->bufptr, (size_t)count); r->bufptr += count; remaining -= count; } diff --git a/filter/rastertoepson.c b/filter/rastertoepson.c index 3996dd808..0975d3e7b 100644 --- a/filter/rastertoepson.c +++ b/filter/rastertoepson.c @@ -520,7 +520,7 @@ CompressData(const unsigned char *line, /* I - Data to compress */ *comp_ptr++ = (unsigned char)(count - 1); - memcpy(comp_ptr, start, count); + memcpy(comp_ptr, start, (size_t)count); comp_ptr += count; } } diff --git a/notifier/dbus.c b/notifier/dbus.c index ae9655109..03a41681e 100644 --- a/notifier/dbus.c +++ b/notifier/dbus.c @@ -417,7 +417,7 @@ main(int argc, /* I - Number of command-line args */ attr = ippFindAttribute(msg, "printer-state", IPP_TAG_ENUM); if (attr) { - dbus_uint32_t val = ippGetInteger(attr, 0); + dbus_uint32_t val = (dbus_uint32_t)ippGetInteger(attr, 0); dbus_message_iter_append_uint32(&iter, &val); } else @@ -446,8 +446,7 @@ main(int argc, /* I - Number of command-line args */ if (i) *p++ = ','; - strlcpy(p, ippGetString(attr, i, NULL), - reasons_length - (p - printer_reasons)); + strlcpy(p, ippGetString(attr, i, NULL), reasons_length - (size_t)(p - printer_reasons)); p += strlen(p); } if (!dbus_message_iter_append_string(&iter, &printer_reasons)) @@ -466,7 +465,7 @@ main(int argc, /* I - Number of command-line args */ IPP_TAG_BOOLEAN); if (attr) { - dbus_bool_t val = ippGetBoolean(attr, 0); + dbus_bool_t val = (dbus_bool_t)ippGetBoolean(attr, 0); dbus_message_iter_append_boolean(&iter, &val); } else @@ -486,7 +485,7 @@ main(int argc, /* I - Number of command-line args */ attr = ippFindAttribute(msg, "notify-job-id", IPP_TAG_INTEGER); if (attr) { - dbus_uint32_t val = ippGetInteger(attr, 0); + dbus_uint32_t val = (dbus_uint32_t)ippGetInteger(attr, 0); dbus_message_iter_append_uint32(&iter, &val); } else @@ -496,7 +495,7 @@ main(int argc, /* I - Number of command-line args */ attr = ippFindAttribute(msg, "job-state", IPP_TAG_ENUM); if (attr) { - dbus_uint32_t val = ippGetInteger(attr, 0); + dbus_uint32_t val = (dbus_uint32_t)ippGetInteger(attr, 0); dbus_message_iter_append_uint32(&iter, &val); } else @@ -519,8 +518,7 @@ main(int argc, /* I - Number of command-line args */ if (i) *p++ = ','; - strlcpy(p, ippGetString(attr, i, NULL), - reasons_length - (p - job_reasons)); + strlcpy(p, ippGetString(attr, i, NULL), reasons_length - (size_t)(p - job_reasons)); p += strlen(p); } if (!dbus_message_iter_append_string(&iter, &job_reasons)) @@ -545,7 +543,7 @@ main(int argc, /* I - Number of command-line args */ IPP_TAG_INTEGER); if (attr) { - dbus_uint32_t val = ippGetInteger(attr, 0); + dbus_uint32_t val = (dbus_uint32_t)ippGetInteger(attr, 0); dbus_message_iter_append_uint32(&iter, &val); } else diff --git a/scheduler/cert.c b/scheduler/cert.c index f86a3cf9c..893ea3314 100644 --- a/scheduler/cert.c +++ b/scheduler/cert.c @@ -408,10 +408,10 @@ cupsdInitCerts(void) * them as the seed... */ - seed = cupsFileGetChar(fp); - seed = (seed << 8) | cupsFileGetChar(fp); - seed = (seed << 8) | cupsFileGetChar(fp); - CUPS_SRAND((seed << 8) | cupsFileGetChar(fp)); + seed = (unsigned)cupsFileGetChar(fp); + seed = (seed << 8) | (unsigned)cupsFileGetChar(fp); + seed = (seed << 8) | (unsigned)cupsFileGetChar(fp); + CUPS_SRAND((seed << 8) | (unsigned)cupsFileGetChar(fp)); cupsFileClose(fp); } diff --git a/scheduler/client.c b/scheduler/client.c index 743df7bc5..23fb71305 100644 --- a/scheduler/client.c +++ b/scheduler/client.c @@ -3,7 +3,7 @@ * * Client routines for the CUPS scheduler. * - * Copyright 2007-2013 by Apple Inc. + * Copyright 2007-2014 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * This file contains Kerberos support code, copyright 2006 by @@ -44,7 +44,7 @@ static int compare_clients(cupsd_client_t *a, cupsd_client_t *b, static int cupsd_start_tls(cupsd_client_t *con, http_encryption_t e); #endif /* HAVE_SSL */ static char *get_file(cupsd_client_t *con, struct stat *filestats, - char *filename, int len); + char *filename, size_t len); static http_status_t install_cupsd_conf(cupsd_client_t *con); static int is_cgi(cupsd_client_t *con, const char *filename, struct stat *filestats, mime_type_t *type); @@ -2636,7 +2636,7 @@ cupsdWriteClient(cupsd_client_t *con) /* I - Client connection */ con->header_used -= bufptr - con->header; if (con->header_used > 0) - memmove(con->header, bufptr, con->header_used); + memmove(con->header, bufptr, (size_t)con->header_used); bufptr = con->header - 1; @@ -2881,11 +2881,11 @@ static char * /* O - Real filename */ get_file(cupsd_client_t *con, /* I - Client connection */ struct stat *filestats, /* O - File information */ char *filename, /* IO - Filename buffer */ - int len) /* I - Buffer length */ + size_t len) /* I - Buffer length */ { int status; /* Status of filesystem calls */ char *ptr; /* Pointer info filename */ - int plen; /* Remaining length after pointer */ + size_t plen; /* Remaining length after pointer */ char language[7]; /* Language subdirectory, if any */ @@ -3008,7 +3008,7 @@ get_file(cupsd_client_t *con, /* I - Client connection */ *ptr = '\0'; ptr = filename + strlen(filename); - plen = len - (ptr - filename); + plen = len - (size_t)(ptr - filename); strlcpy(ptr, "index.html", plen); status = stat(filename, filestats); @@ -3055,10 +3055,7 @@ get_file(cupsd_client_t *con, /* I - Client connection */ while (status && language[0]); } - cupsdLogClient(con, CUPSD_LOG_DEBUG2, - "get_file filestats=%p, filename=%p, len=%d, " - "returning \"%s\".", filestats, filename, len, - status ? "(null)" : filename); + cupsdLogClient(con, CUPSD_LOG_DEBUG2, "get_file filestats=%p, filename=%p, len=" CUPS_LLFMT ", returning \"%s\".", filestats, filename, CUPS_LLCAST len, status ? "(null)" : filename); if (status) return (NULL); diff --git a/scheduler/cups-exec.c b/scheduler/cups-exec.c index 1111f7d07..29ded7f72 100644 --- a/scheduler/cups-exec.c +++ b/scheduler/cups-exec.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #ifdef HAVE_SANDBOX_H # include diff --git a/scheduler/cups-lpd.c b/scheduler/cups-lpd.c index a1de09058..50a5cb1f4 100644 --- a/scheduler/cups-lpd.c +++ b/scheduler/cups-lpd.c @@ -59,7 +59,7 @@ static int create_job(http_t *http, const char *dest, const char *title, const char *docname, const char *user, int num_options, cups_option_t *options); static int get_printer(http_t *http, const char *name, char *dest, - int destsize, cups_option_t **options, + size_t destsize, cups_option_t **options, int *accepting, int *shared, ipp_pstate_t *state); static int print_file(http_t *http, int id, const char *filename, const char *docname, const char *user, @@ -398,7 +398,7 @@ static int /* O - Number of options or -1 on error */ get_printer(http_t *http, /* I - HTTP connection */ const char *name, /* I - Printer name from request */ char *dest, /* I - Destination buffer */ - int destsize, /* I - Size of destination buffer */ + size_t destsize, /* I - Size of destination buffer */ cups_option_t **options, /* O - Printer options */ int *accepting, /* O - printer-is-accepting-jobs value */ int *shared, /* O - printer-is-shared value */ diff --git a/scheduler/cupsd.h b/scheduler/cupsd.h index 128066246..d0f8fb5c4 100644 --- a/scheduler/cupsd.h +++ b/scheduler/cupsd.h @@ -204,8 +204,7 @@ extern void cupsdSetStringf(char **s, const char *f, ...) extern void *cupsdCreateProfile(int job_id, int allow_networking); extern void cupsdDestroyProfile(void *profile); extern int cupsdEndProcess(int pid, int force); -extern const char *cupsdFinishProcess(int pid, char *name, int namelen, - int *job_id); +extern const char *cupsdFinishProcess(int pid, char *name, size_t namelen, int *job_id); extern int cupsdStartProcess(const char *command, char *argv[], char *envp[], int infd, int outfd, int errfd, int backfd, int sidefd, diff --git a/scheduler/file.c b/scheduler/file.c index 0d236c918..210243641 100644 --- a/scheduler/file.c +++ b/scheduler/file.c @@ -1,30 +1,16 @@ /* * "$Id$" * - * File functions for the CUPS scheduler. + * File functions for the CUPS scheduler. * - * Copyright 2007-2013 by Apple Inc. - * Copyright 1997-2007 by Easy Software Products, all rights reserved. + * Copyright 2007-2014 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" - * "LICENSE" which should have been included with this file. If this - * file is missing or damaged, see the license at "http://www.cups.org/". - * - * Contents: - * - * cupsdCleanFiles() - Clean out old files. - * cupsdCloseCreatedConfFile() - Close a created configuration file and move - * into place. - * cupsdClosePipe() - Close a pipe as necessary. - * cupsdCreateConfFile() - Create a configuration file safely. - * cupsdOpenConfFile() - Open a configuration file. - * cupsdOpenPipe() - Create a pipe which is closed on exec. - * cupsdRemoveFile() - Remove a file securely. - * cupsdUnlinkOrRemoveFile() - Unlink or securely remove a file depending - * on the configuration. - * overwrite_data() - Overwrite the data in a file. + * 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" + * "LICENSE" which should have been included with this file. If this + * file is missing or damaged, see the license at "http://www.cups.org/". */ /* @@ -445,7 +431,7 @@ overwrite_data(int fd, /* I - File descriptor */ else bytes = filesize; - if ((bytes = write(fd, buffer, bytes)) < 0) + if ((bytes = write(fd, buffer, (size_t)bytes)) < 0) return (-1); filesize -= bytes; diff --git a/scheduler/ipp.c b/scheduler/ipp.c index c5335c698..d00fddb41 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -129,15 +129,12 @@ static void set_printer_defaults(cupsd_client_t *con, cupsd_printer_t *printer); static void start_printer(cupsd_client_t *con, ipp_attribute_t *uri); static void stop_printer(cupsd_client_t *con, ipp_attribute_t *uri); -static void url_encode_attr(ipp_attribute_t *attr, char *buffer, - int bufsize); -static char *url_encode_string(const char *s, char *buffer, int bufsize); +static void url_encode_attr(ipp_attribute_t *attr, char *buffer, size_t bufsize); +static char *url_encode_string(const char *s, char *buffer, size_t bufsize); static int user_allowed(cupsd_printer_t *p, const char *username); static void validate_job(cupsd_client_t *con, ipp_attribute_t *uri); static int validate_name(const char *name); -static int validate_user(cupsd_job_t *job, cupsd_client_t *con, - const char *owner, char *username, - int userlen); +static int validate_user(cupsd_job_t *job, cupsd_client_t *con, const char *owner, char *username, size_t userlen); /* @@ -2115,7 +2112,7 @@ add_job_subscriptions( { sub->user_data_len = user_data->values[0].unknown.length; memcpy(sub->user_data, user_data->values[0].unknown.data, - sub->user_data_len); + (size_t)sub->user_data_len); } ippAddSeparator(con->response); @@ -5555,7 +5552,7 @@ create_subscription( { sub->user_data_len = user_data->values[0].unknown.length; memcpy(sub->user_data, user_data->values[0].unknown.data, - sub->user_data_len); + (size_t)sub->user_data_len); } ippAddSeparator(con->response); @@ -10554,7 +10551,7 @@ stop_printer(cupsd_client_t *con, /* I - Client connection */ static void url_encode_attr(ipp_attribute_t *attr, /* I - Attribute */ char *buffer,/* I - String buffer */ - int bufsize)/* I - Size of buffer */ + size_t bufsize)/* I - Size of buffer */ { int i; /* Looping var */ char *bufptr, /* Pointer into buffer */ @@ -10580,8 +10577,7 @@ url_encode_attr(ipp_attribute_t *attr, /* I - Attribute */ *bufptr++ = '\''; - bufptr = url_encode_string(attr->values[i].string.text, - bufptr, bufend - bufptr + 1); + bufptr = url_encode_string(attr->values[i].string.text, bufptr, (size_t)(bufend - bufptr + 1)); if (bufptr >= bufend) break; @@ -10600,7 +10596,7 @@ url_encode_attr(ipp_attribute_t *attr, /* I - Attribute */ static char * /* O - End of string */ url_encode_string(const char *s, /* I - String */ char *buffer, /* I - String buffer */ - int bufsize) /* I - Size of buffer */ + size_t bufsize) /* I - Size of buffer */ { char *bufptr, /* Pointer into buffer */ *bufend; /* End of buffer */ @@ -10955,16 +10951,12 @@ validate_user(cupsd_job_t *job, /* I - Job */ cupsd_client_t *con, /* I - Client connection */ const char *owner, /* I - Owner of job/resource */ char *username, /* O - Authenticated username */ - int userlen) /* I - Length of username */ + size_t userlen) /* I - Length of username */ { cupsd_printer_t *printer; /* Printer for job */ - cupsdLogMessage(CUPSD_LOG_DEBUG2, - "validate_user(job=%d, con=%d, owner=\"%s\", username=%p, " - "userlen=%d)", - job->id, con ? con->number : 0, - owner ? owner : "(null)", username, userlen); + cupsdLogMessage(CUPSD_LOG_DEBUG2, "validate_user(job=%d, con=%d, owner=\"%s\", username=%p, userlen=" CUPS_LLFMT ")", job->id, con ? con->number : 0, owner ? owner : "(null)", username, CUPS_LLCAST userlen); /* * Validate input... diff --git a/scheduler/log.c b/scheduler/log.c index 5d5dba617..527f4ccb0 100644 --- a/scheduler/log.c +++ b/scheduler/log.c @@ -722,7 +722,7 @@ cupsdLogPage(cupsd_job_t *job, /* I - Job being printed */ * Pull the name from inside the brackets... */ - memcpy(name, format + 1, nameend - format - 1); + memcpy(name, format + 1, (size_t)(nameend - format - 1)); name[nameend - format - 1] = '\0'; format = nameend; diff --git a/scheduler/printers.c b/scheduler/printers.c index 6d7f1ce20..ca857c703 100644 --- a/scheduler/printers.c +++ b/scheduler/printers.c @@ -1491,8 +1491,7 @@ cupsdSaveAllPrinters(void) if (i) *ptr++ = ','; - strlcpy(ptr, marker->values[i].string.text, - value + sizeof(value) - ptr); + strlcpy(ptr, marker->values[i].string.text, (size_t)(value + sizeof(value) - ptr)); ptr += strlen(ptr); } @@ -1551,8 +1550,7 @@ cupsdSaveAllPrinters(void) if (i) *ptr++ = ','; - strlcpy(ptr, marker->values[i].string.text, - value + sizeof(value) - ptr); + strlcpy(ptr, marker->values[i].string.text, (size_t)(value + sizeof(value) - ptr)); ptr += strlen(ptr); } @@ -1572,8 +1570,7 @@ cupsdSaveAllPrinters(void) if (i) *ptr++ = ','; - strlcpy(ptr, marker->values[i].string.text, - value + sizeof(value) - ptr); + strlcpy(ptr, marker->values[i].string.text, (size_t)(value + sizeof(value) - ptr)); ptr += strlen(ptr); } diff --git a/scheduler/process.c b/scheduler/process.c index 6afb5926c..469e77a68 100644 --- a/scheduler/process.c +++ b/scheduler/process.c @@ -369,10 +369,10 @@ cupsdEndProcess(int pid, /* I - Process ID */ */ const char * /* O - Process name */ -cupsdFinishProcess(int pid, /* I - Process ID */ - char *name, /* I - Name buffer */ - int namelen, /* I - Size of name buffer */ - int *job_id) /* O - Job ID pointer or NULL */ +cupsdFinishProcess(int pid, /* I - Process ID */ + char *name, /* I - Name buffer */ + size_t namelen, /* I - Size of name buffer */ + int *job_id) /* O - Job ID pointer or NULL */ { cupsd_proc_t key, /* Search key */ *proc; /* Matching process */ @@ -397,10 +397,7 @@ cupsdFinishProcess(int pid, /* I - Process ID */ strlcpy(name, "unknown", namelen); } - cupsdLogMessage(CUPSD_LOG_DEBUG2, - "cupsdFinishProcess(pid=%d, name=%p, namelen=%d, " - "job_id=%p(%d)) = \"%s\"", pid, name, namelen, job_id, - job_id ? *job_id : 0, name); + cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdFinishProcess(pid=%d, name=%p, namelen=" CUPS_LLFMT ", job_id=%p(%d)) = \"%s\"", pid, name, CUPS_LLCAST namelen, job_id, job_id ? *job_id : 0, name); return (name); } @@ -437,10 +434,9 @@ cupsdStartProcess( char user_str[16], /* User string */ group_str[16], /* Group string */ nice_str[16]; /* FilterNice string */ -#endif /* HAVE_POSIX_SPAWN */ -#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) +#elif defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) struct sigaction action; /* POSIX signal handler */ -#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ +#endif /* HAVE_POSIX_SPAWN */ #if defined(__APPLE__) char processPath[1024], /* CFProcessPath environment variable */ linkpath[1024]; /* Link path for symlinks... */ diff --git a/scheduler/select.c b/scheduler/select.c index 08b91714b..d302db0af 100644 --- a/scheduler/select.c +++ b/scheduler/select.c @@ -518,15 +518,13 @@ cupsdDoSelect(long timeout) /* I - Timeout in seconds */ if (cupsd_pollfds) - pfd = realloc(cupsd_pollfds, allocfds * sizeof(struct pollfd)); + pfd = realloc(cupsd_pollfds, (size_t)allocfds * sizeof(struct pollfd)); else - pfd = malloc(allocfds * sizeof(struct pollfd)); + pfd = malloc((size_t)allocfds * sizeof(struct pollfd)); if (!pfd) { - cupsdLogMessage(CUPSD_LOG_EMERG, - "Unable to allocate %d bytes for polling!", - (int)(allocfds * sizeof(struct pollfd))); + cupsdLogMessage(CUPSD_LOG_EMERG, "Unable to allocate %d bytes for polling.", (int)((size_t)allocfds * sizeof(struct pollfd))); return (-1); } @@ -555,9 +553,9 @@ cupsdDoSelect(long timeout) /* I - Timeout in seconds */ } if (timeout >= 0 && timeout < 86400) - nfds = poll(cupsd_pollfds, count, timeout * 1000); + nfds = poll(cupsd_pollfds, (nfds_t)count, timeout * 1000); else - nfds = poll(cupsd_pollfds, count, -1); + nfds = poll(cupsd_pollfds, (nfds_t)count, -1); if (nfds > 0) { @@ -808,7 +806,7 @@ cupsdStartSelect(void) #ifdef HAVE_EPOLL cupsd_epoll_fd = epoll_create(MaxFDs); - cupsd_epoll_events = calloc(MaxFDs, sizeof(struct epoll_event)); + cupsd_epoll_events = calloc((size_t)MaxFDs, sizeof(struct epoll_event)); cupsd_update_pollfds = 0; #elif defined(HAVE_KQUEUE) diff --git a/scheduler/statbuf.c b/scheduler/statbuf.c index 518fc12be..1c2bd74e6 100644 --- a/scheduler/statbuf.c +++ b/scheduler/statbuf.c @@ -305,7 +305,7 @@ cupsdStatBufUpdate( * Copy the message to the line buffer... */ - strlcpy(line, message, linelen); + strlcpy(line, message, (size_t)linelen); /* * Copy over the buffer data we've used up... diff --git a/scheduler/type.c b/scheduler/type.c index 8357197f3..60bc0ca5d 100644 --- a/scheduler/type.c +++ b/scheduler/type.c @@ -528,7 +528,7 @@ mimeAddTypeRule(mime_type_t *mt, /* I - Type to add to */ if ((size_t)length[1] > sizeof(temp->value.stringv)) return (-1); temp->length = length[1]; - memcpy(temp->value.stringv, value[1], length[1]); + memcpy(temp->value.stringv, value[1], (size_t)length[1]); break; case MIME_MAGIC_CHAR : temp->offset = strtol(value[0], NULL, 0); @@ -560,7 +560,7 @@ mimeAddTypeRule(mime_type_t *mt, /* I - Type to add to */ if ((size_t)length[2] > sizeof(temp->value.stringv)) return (-1); temp->length = length[2]; - memcpy(temp->value.stringv, value[2], length[2]); + memcpy(temp->value.stringv, value[2], (size_t)length[2]); break; } } @@ -886,7 +886,7 @@ mime_check_rules( char temp[MIME_MAX_BUFFER + 1]; /* Temporary buffer */ - memcpy(temp, fb->buffer, fb->length); + memcpy(temp, fb->buffer, (size_t)fb->length); temp[fb->length] = '\0'; result = !regexec(&(rules->value.rev), temp, 0, NULL, 0); } diff --git a/test/ippfind.c b/test/ippfind.c index 59dbdbf77..5485c9f8b 100644 --- a/test/ippfind.c +++ b/test/ippfind.c @@ -2281,7 +2281,7 @@ list_service(ippfind_srv_t *service) /* I - Service */ i ++, ptr += strlen(ptr)) { *ptr++ = ','; - strlcpy(ptr, ippGetString(attr, i, NULL), end - ptr + 1); + strlcpy(ptr, ippGetString(attr, i, NULL), (size_t)(end - ptr + 1)); } } else diff --git a/test/ipptool.c b/test/ipptool.c index e32ef571c..00124c1f0 100644 --- a/test/ipptool.c +++ b/test/ipptool.c @@ -2257,7 +2257,7 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ last_expect->with_flags |= _CUPS_WITH_REGEX; if (last_expect->with_value) - memcpy(last_expect->with_value, token + 1, tokenptr - token - 1); + memcpy(last_expect->with_value, token + 1, (size_t)(tokenptr - token - 1)); } else { @@ -3348,7 +3348,7 @@ expand_variables(_cups_vars_t *vars, /* I - Variables */ if (value) { - strlcpy(dstptr, value, dstend - dstptr + 1); + strlcpy(dstptr, value, (size_t)(dstend - dstptr + 1)); dstptr += strlen(dstptr); } } -- 2.39.2