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",
* 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",
* 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;
* 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
*/
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;
length -= 2;
- memmove(device_id, device_id + 2, length);
+ memmove(device_id, device_id + 2, (size_t)length);
device_id[length] = '\0';
}
}
*/
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...
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)
{
}
else
{
- memcpy(temp, data, datalen);
+ memcpy(temp, data, (size_t)datalen);
temp[datalen] = '\0';
}
/*
* "$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/".
*/
/*
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;
* 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
*/
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;
* nul-terminate.
*/
- memmove(buffer, buffer + 2, length);
+ memmove(buffer, buffer + 2, (size_t)length);
buffer[length] = '\0';
return (0);
{
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);
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 = " ";
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 :
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 :
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 :
wordlen = (int)(ptr - text);
- memcpy(temp, text, wordlen);
+ memcpy(temp, text, (size_t)wordlen);
temp[wordlen] = '\0';
ptr --;
* Make URI relative to the current server...
*/
- strlcpy(url, resource, urlsize);
+ strlcpy(url, resource, (size_t)urlsize);
}
else
{
*/
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);
}
*/
write(fd, line, 8192);
- memmove(line, line + 8192, ptr - line - 8192);
+ memmove(line, line + 8192, (size_t)(ptr - line - 8192));
ptr -= 8192;
}
}
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,
_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 */
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);
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));
{
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 :
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;
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;
* 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);
}
}
* options...
*/
- strlcpy(bufptr, "[{\n", bufend - bufptr + 1);
+ strlcpy(bufptr, "[{\n", (size_t)(bufend - bufptr + 1));
bufptr += 3;
/*
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");
* 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);
}
}
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);
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;
{
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
}
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')
}
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...",
}
else
{
- strlcpy(bufptr, choices[i]->code, bufend - bufptr + 1);
+ strlcpy(bufptr, choices[i]->code, (size_t)(bufend - bufptr + 1));
bufptr += strlen(bufptr);
}
if (!access(filename, 0))
{
- strlcpy(buffer, filename, bufsize);
+ strlcpy(buffer, filename, (size_t)bufsize);
return (buffer);
}
else
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))
if (bufptr > buffer && bufptr[-1] != '/' && bufptr < bufend)
*bufptr++ = '/';
- strlcpy(bufptr, filename, bufend - bufptr);
+ strlcpy(bufptr, filename, (size_t)(bufend - bufptr));
if (!access(buffer, 0))
{
}
else
{
- memcpy(fp->ptr, fp->printf_buffer, bytes);
+ memcpy(fp->ptr, fp->printf_buffer, (size_t)bytes);
fp->ptr += bytes;
return ((int)bytes);
}
}
else
{
- memcpy(fp->ptr, s, bytes);
+ memcpy(fp->ptr, s, (size_t)bytes);
fp->ptr += bytes;
return ((int)bytes);
}
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;
*/
if ((bytes = end - ptr) > 0)
- memcpy(fp->cbuf, ptr, bytes);
+ memcpy(fp->cbuf, ptr, (size_t)bytes);
/*
* Setup the decompressor data...
#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 */
if (httpAddrLocalhost(addr))
{
- strlcpy(name, "localhost", namelen);
+ strlcpy(name, "localhost", (size_t)namelen);
return (name);
}
return (httpAddrString(addr, name, namelen));
}
- strlcpy(name, host->h_name, namelen);
+ strlcpy(name, host->h_name, (size_t)namelen);
}
#endif /* HAVE_GETNAMEINFO */
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 */
{
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
{
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);
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);
}
}
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);
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);
}
}
* Empty at end...
*/
- strlcpy(sptr, "::", sizeof(temps) - (sptr - temps));
+ strlcpy(sptr, "::", sizeof(temps) - (size_t)(sptr - temps));
}
}
# endif /* HAVE_GETNAMEINFO */
* 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));
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
{
return (NULL);
if (gethostname(s, (size_t)slen) < 0)
- strlcpy(s, "localhost", slen);
+ strlcpy(s, "localhost", (size_t)slen);
if (!strchr(s, '.'))
{
* Append ".local." to the hostname we get...
*/
- snprintf(s, slen, "%s.local.", localStr);
+ snprintf(s, (size_t)slen, "%s.local.", localStr);
}
if (local)
* Use the resolved hostname...
*/
- strlcpy(s, host->h_name, slen);
+ strlcpy(s, host->h_name, (size_t)slen);
}
#endif /* HAVE_SCDYNAMICSTORECOPYCOMPUTERNAME */
}
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)
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';
* 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 == '/')
* Filename...
*/
- strlcpy(scheme, "file", schemelen);
+ strlcpy(scheme, "file", (size_t)schemelen);
status = HTTP_URI_STATUS_MISSING_SCHEME;
}
else
{
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)
{
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)
{
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,
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);
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 :
val->date[10]);
if (buffer && bufptr < bufend)
- strlcpy(bufptr, temp, bufend - bufptr + 1);
+ strlcpy(bufptr, temp, (size_t)(bufend - bufptr + 1));
bufptr += strlen(temp);
}
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)
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
{
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;
}
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;
return (NULL);
}
- memcpy(attr->values[0].unknown.data, data, datalen);
+ memcpy(attr->values[0].unknown.data, data, (size_t)datalen);
}
/*
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 */
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);
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;
*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
*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)
if (n > 0)
{
- memcpy(bufptr, value->string.text, n);
+ memcpy(bufptr, value->string.text, (size_t)n);
bufptr += n;
}
}
/* Language */
if (n > 0)
{
- memcpy(bufptr, value->string.language, n);
+ memcpy(bufptr, value->string.language, (size_t)n);
bufptr += n;
}
/* Text */
if (n > 0)
{
- memcpy(bufptr, value->string.text, n);
+ memcpy(bufptr, value->string.text, (size_t)n);
bufptr += n;
}
}
/* Value */
if (n > 0)
{
- memcpy(bufptr, value->unknown.data, n);
+ memcpy(bufptr, value->unknown.data, (size_t)n);
bufptr += n;
}
}
* 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);
/*
*/
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 */
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;
/* Process a final partial block. */
if (left)
- memcpy(pms->buf, p, left);
+ memcpy(pms->buf, p, (size_t)left);
}
void
* 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';
}
*status = (cups_sc_status_t)buffer[1];
*datalen = templen;
- memcpy(data, buffer + 4, templen);
+ memcpy(data, buffer + 4, (size_t)templen);
}
_cupsBufferRelease(buffer);
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;
if (datalen > 0)
{
- memcpy(buffer + 4, data, datalen);
+ memcpy(buffer + 4, data, (size_t)datalen);
bytes += datalen;
}
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);
}
else
{
- strlcpy(buf, temp, bufend - buf + 1);
+ strlcpy(buf, temp, (size_t)(bufend - buf + 1));
bufptr = buf + strlen(buf);
}
/*
* "$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.
*/
/*
* 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...
* 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 */
/*
# include <unistd.h>
# include <fcntl.h>
#endif /* WIN32 */
+#include <math.h>
/*
*/
+/*
+ * 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...
*/
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.
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)
{
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)
{
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));
}
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));
}
* 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)
{
*/
if (ptr != p)
- memcpy(p, ptr, bytes);
+ memcpy(p, ptr, (size_t)bytes);
}
else
{
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)
* Copy the raster data to the buffer...
*/
- memcpy(r->pcurrent, p, bytes);
+ memcpy(r->pcurrent, p, (size_t)bytes);
r->pcurrent += bytes;
* Use memcpy() for a large read...
*/
- memcpy(buf, r->bufptr, count);
+ memcpy(buf, r->bufptr, (size_t)count);
r->bufptr += count;
remaining -= count;
}
*comp_ptr++ = (unsigned char)(count - 1);
- memcpy(comp_ptr, start, count);
+ memcpy(comp_ptr, start, (size_t)count);
comp_ptr += count;
}
}
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
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))
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
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
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
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))
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
* 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);
}
*
* 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
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);
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;
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 */
*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);
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);
#include <cups/file.h>
#include <unistd.h>
#include <fcntl.h>
+#include <grp.h>
#include <sys/stat.h>
#ifdef HAVE_SANDBOX_H
# include <sandbox.h>
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,
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 */
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,
/*
* "$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/".
*/
/*
else
bytes = filesize;
- if ((bytes = write(fd, buffer, bytes)) < 0)
+ if ((bytes = write(fd, buffer, (size_t)bytes)) < 0)
return (-1);
filesize -= bytes;
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);
/*
{
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);
{
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);
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 */
*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;
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 */
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...
* 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;
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);
}
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);
}
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);
}
*/
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 */
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);
}
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... */
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);
}
}
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)
{
#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)
* 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...
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);
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;
}
}
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);
}
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
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
{
if (value)
{
- strlcpy(dstptr, value, dstend - dstptr + 1);
+ strlcpy(dstptr, value, (size_t)(dstend - dstptr + 1));
dstptr += strlen(dstptr);
}
}