device_id[0] = '\0';
make_and_model[0] = '\0';
- strcpy(model, "Unknown");
+ strlcpy(model, "Unknown", sizeof(model));
for (data = rdata, dataend = data + rdlen;
data < dataend;
if (!_cups_strcasecmp(key, "usb_MFG") || !_cups_strcasecmp(key, "usb_MANU") ||
!_cups_strcasecmp(key, "usb_MANUFACTURER"))
- strcpy(make_and_model, value);
+ strlcpy(make_and_model, value, sizeof(make_and_model));
else if (!_cups_strcasecmp(key, "usb_MDL") || !_cups_strcasecmp(key, "usb_MODEL"))
- strcpy(model, value);
+ strlcpy(model, value, sizeof(model));
else if (!_cups_strcasecmp(key, "product") && !strstr(value, "Ghostscript"))
{
if (value[0] == '(')
if ((ptr = value + strlen(value) - 1) > value && *ptr == ')')
*ptr = '\0';
- strcpy(model, value + 1);
+ strlcpy(model, value + 1, sizeof(model));
}
else
- strcpy(model, value);
+ strlcpy(model, value, sizeof(model));
}
else if (!_cups_strcasecmp(key, "ty"))
{
- strcpy(model, value);
+ strlcpy(model, value, sizeof(model));
if ((ptr = strchr(model, ',')) != NULL)
*ptr = '\0';
if (!make ||
!CFStringGetCString(make, makestr, sizeof(makestr),
kCFStringEncodingUTF8))
- strcpy(makestr, "Unknown");
+ strlcpy(makestr, "Unknown", sizeof(makestr));
if (!model ||
!CFStringGetCString(model, &modelstr[1], sizeof(modelstr)-1,
kCFStringEncodingUTF8))
- strcpy(modelstr + 1, "Printer");
+ strlcpy(modelstr + 1, "Printer", sizeof(modelstr) - 1);
optionsstr[0] = '\0';
if (serial != NULL)
}
/* move everything over... */
- strcpy(gErrorBuffer, pLineEnd);
+ strlcpy(gErrorBuffer, pLineEnd, sizeof(gErrorBuffer));
gErrorBufferPtr = gErrorBuffer;
pLineEnd = (char *)next_line((const char *)gErrorBuffer);
}
*/
if (jobstate == IPP_JOB_PROCESSING)
- strcpy(rankstr, "active");
+ strlcpy(rankstr, "active", sizeof(rankstr));
else
{
/*
else if (!_cups_strncasecmp(make, "laserjet", 8) ||
!_cups_strncasecmp(make, "deskjet", 7) ||
!_cups_strncasecmp(make, "designjet", 9))
- strcpy(make, "HP");
+ strlcpy(make, "HP", sizeof(make));
else if (!_cups_strncasecmp(make, "phaser", 6))
- strcpy(make, "Xerox");
+ strlcpy(make, "Xerox", sizeof(make));
else if (!_cups_strncasecmp(make, "stylus", 6))
- strcpy(make, "Epson");
+ strlcpy(make, "Epson", sizeof(make));
else
- strcpy(make, "Generic");
+ strlcpy(make, "Generic", sizeof(make));
if (!cgiGetVariable("CURRENT_MAKE"))
cgiSetVariable("CURRENT_MAKE", make);
if (bufptr == buffer || (bufend - bufptr) < 2)
return (NULL);
- strcpy(bufptr, "}");
+ memcpy(bufptr, "}", 2);
}
return (buffer);
*
* Online help index routines for CUPS.
*
- * Copyright 2007-2011 by Apple Inc.
+ * Copyright 2007-2012 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
node = NULL;
offset = 0;
- strcpy(section, "Other");
+ strlcpy(section, "Other", sizeof(section));
while (cupsFileGets(fp, line, sizeof(line)))
{
*nameptr = '\0';
if (!strncmp(name, "printer_state_history", 21))
- strcpy(name, "printer_state_history");
+ strlcpy(name, "printer_state_history", sizeof(name));
/*
* Possibly add it to the list of attributes...
char url[1024]; /* Encoded URL */
- strcpy(url, "5;URL=");
+ strlcpy(url, "5;URL=", sizeof(url));
cgiFormEncode(url + 6, getenv("HTTP_REFERER"), sizeof(url) - 6);
cgiSetVariable("refresh_page", url);
}
*
* Search routines for CUPS.
*
- * Copyright 2007-2011 by Apple Inc.
+ * Copyright 2007-2012 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
* Add the prefix string...
*/
- strcpy(sptr, prefix);
+ memcpy(sptr, prefix, strlen(prefix) + 1);
sptr += strlen(sptr);
/*
return (NULL);
}
- strcpy(sptr, ".*|.*");
+ memcpy(sptr, ".*|.*", 6);
sptr += 5;
- strcpy(sptr, lword2);
+ memcpy(sptr, lword2, strlen(lword2) + 1);
sptr += strlen(sptr);
- strcpy(sptr, ".*");
+ memcpy(sptr, ".*", 3);
sptr += 2;
- strcpy(sptr, lword);
+ memcpy(sptr, lword, strlen(lword) + 1);
sptr += strlen(sptr);
free(lword);
free(lword);
if (sptr > s)
- strcpy(sptr, ".*");
+ memcpy(sptr, ".*", 3);
else
{
/*
authsize = sizeof(http->_authstring);
}
- strcpy(http->authstring, "Negotiate ");
+ strlcpy(http->authstring, "Negotiate ", authsize);
httpEncode64_2(http->authstring + 10, authsize - 10, output_token.value,
output_token.length);
if (!_cups_strncasecmp(option, "Custom", 6) && !_cups_strcasecmp(choice, "True"))
{
_cups_strcpy(option, option + 6);
- strcpy(choice, "Custom");
+ strlcpy(choice, "Custom", sizeof(choice));
}
constptr->option = ppdFindOption(ppd, option);
if (bufptr)
{
- if ((bufptr + strlen(temp)) > bufend)
- {
- strncpy(bufptr, temp, (size_t)(bufend - bufptr));
- bufptr = bufend;
- }
- else
- {
- strcpy(bufptr, temp);
- bufptr += strlen(temp);
- }
+ strlcpy(bufptr, temp, (size_t)(bufend - bufptr));
+ bufptr += strlen(bufptr);
}
break;
if (bufptr)
{
- if ((bufptr + strlen(temp)) > bufend)
- {
- strncpy(bufptr, temp, (size_t)(bufend - bufptr));
- bufptr = bufend;
- }
- else
- {
- strcpy(bufptr, temp);
- bufptr += strlen(temp);
- }
+ strlcpy(bufptr, temp, (size_t)(bufend - bufptr));
+ bufptr += strlen(bufptr);
}
break;
if (bufptr)
{
- if ((bufptr + strlen(temp)) > bufend)
- {
- strncpy(bufptr, temp, (size_t)(bufend - bufptr));
- bufptr = bufend;
- }
- else
- {
- strcpy(bufptr, temp);
- bufptr += strlen(temp);
- }
+ strlcpy(bufptr, temp, (size_t)(bufend - bufptr));
+ bufptr += strlen(bufptr);
}
break;
device->state = _CUPS_DNSSD_PENDING;
make_and_model[0] = '\0';
- strcpy(model, "Unknown");
+ strlcpy(model, "Unknown", sizeof(model));
for (txt = rdata, txtend = txt + rdlen;
txt < txtend;
if (!_cups_strcasecmp(key, "usb_MFG") ||
!_cups_strcasecmp(key, "usb_MANU") ||
!_cups_strcasecmp(key, "usb_MANUFACTURER"))
- strcpy(make_and_model, value);
+ strlcpy(make_and_model, value, sizeof(make_and_model));
else if (!_cups_strcasecmp(key, "usb_MDL") ||
!_cups_strcasecmp(key, "usb_MODEL"))
- strcpy(model, value);
+ strlcpy(model, value, sizeof(model));
else if (!_cups_strcasecmp(key, "product") && !strstr(value, "Ghostscript"))
{
if (value[0] == '(')
if ((ptr = value + strlen(value) - 1) > value && *ptr == ')')
*ptr = '\0';
- strcpy(model, value + 1);
+ strlcpy(model, value + 1, sizeof(model));
}
else
- strcpy(model, value);
+ strlcpy(model, value, sizeof(model));
}
else if (!_cups_strcasecmp(key, "ty"))
{
- strcpy(model, value);
+ strlcpy(model, value, sizeof(model));
if ((ptr = strchr(model, ',')) != NULL)
*ptr = '\0';
* Open the registry...
*/
- strcpy(installdir, "C:/Program Files/cups.org");
+ strlcpy(installdir, "C:/Program Files/cups.org", sizeof(installdir));
if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\cups.org", 0, KEY_READ,
&key))
if (!length)
{
- strcpy(http->fields[HTTP_FIELD_TRANSFER_ENCODING], "chunked");
+ strlcpy(http->fields[HTTP_FIELD_TRANSFER_ENCODING], "chunked",
+ HTTP_MAX_VALUE);
http->fields[HTTP_FIELD_CONTENT_LENGTH][0] = '\0';
}
else
while (j < 16)
{
- strcpy(ptr, " ");
+ memcpy(ptr, " ", 3);
ptr += 2;
j ++;
}
- strcpy(ptr, " ");
+ memcpy(ptr, " ", 3);
ptr += 2;
for (j = 0; j < 16 && (i + j) < bytes; j ++)
*
* Localized printf/puts functions for CUPS.
*
- * Copyright 2007-2011 by Apple Inc.
+ * Copyright 2007-2012 by Apple Inc.
* Copyright 2002-2007 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
strlcpy(charset, ".UTF-8", sizeof(new_lc_time) - (charset - new_lc_time));
}
else
- strcpy(new_lc_time, "C");
+ strlcpy(new_lc_time, "C", sizeof(new_lc_time));
setlocale(LC_TIME, new_lc_time);
#endif /* LC_TIME */
* Set the character set to UTF-8...
*/
- strcpy(charset, "UTF8");
+ strlcpy(charset, "UTF8", sizeof(charset));
/*
* Apple's setlocale doesn't give us the user's localization
*/
if (!charset[0])
- strcpy(charset, "UTF8");
+ strlcpy(charset, "UTF8", sizeof(charset));
/*
* Parse the language string passed in to a locale string. "C" is the
if (language == NULL || !language[0] ||
!strcmp(language, "POSIX"))
- strcpy(langname, "C");
+ strlcpy(langname, "C", sizeof(langname));
else
{
/*
if (strlen(langname) != 2)
{
- strcpy(langname, "C");
+ strlcpy(langname, "C", sizeof(langname));
country[0] = '\0';
charset[0] = '\0';
}
if (country[0])
snprintf(real, sizeof(real), "%s_%s", langname, country);
else
- strcpy(real, langname);
+ strlcpy(real, langname, sizeof(real));
_cupsMutexLock(&lang_mutex);
*ptr, /* Pointer into buffer */
*temp; /* New string */
int length; /* Length of combined strings */
+ size_t ptrlen; /* Length of string */
DEBUG_printf(("4_cupsMessageLoad(filename=\"%s\")", filename));
*/
length = (int)strlen(m->str ? m->str : m->id);
+ ptrlen = strlen(ptr);
if ((temp = realloc(m->str ? m->str : m->id,
- length + strlen(ptr) + 1)) == NULL)
+ length + ptrlen + 1)) == NULL)
{
if (m->str)
free(m->str);
{
/*
* Copy the new portion to the end of the msgstr string - safe
- * to use strcpy because the buffer is allocated to the correct
+ * to use memcpy because the buffer is allocated to the correct
* size...
*/
m->str = temp;
- strcpy(m->str + length, ptr);
+ memcpy(m->str + length, ptr, ptrlen + 1);
}
else
{
/*
* Copy the new portion to the end of the msgid string - safe
- * to use strcpy because the buffer is allocated to the correct
+ * to use memcpy because the buffer is allocated to the correct
* size...
*/
m->id = temp;
- strcpy(m->id + length, ptr);
+ memcpy(m->id + length, ptr, ptrlen + 1);
}
}
else if (!strncmp(s, "msgstr", 6) && m)
ppd->patches = temp;
- strcpy(ppd->patches + strlen(ppd->patches), string);
+ memcpy(ppd->patches + strlen(ppd->patches), string, strlen(string) + 1);
}
}
else if (!strcmp(keyword, "OpenUI"))
*/
if (!_cups_strcasecmp(name, "PageRegion"))
- strcpy(custom_name, "CustomPageSize");
+ strlcpy(custom_name, "CustomPageSize", sizeof(custom_name));
else
snprintf(custom_name, sizeof(custom_name), "Custom%s", name);
cupsCharsetToUTF8((cups_utf8_t *)choice->text, text,
sizeof(choice->text), encoding);
else if (!strcmp(name, "True"))
- strcpy(choice->text, _("Yes"));
+ strlcpy(choice->text, _("Yes"), sizeof(choice->text));
else if (!strcmp(name, "False"))
- strcpy(choice->text, _("No"));
+ strlcpy(choice->text, _("No"), sizeof(choice->text));
else
strlcpy(choice->text, name, sizeof(choice->text));
*
* snprintf functions for CUPS.
*
- * Copyright 2007-2010 by Apple Inc.
+ * Copyright 2007-2012 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
char tformat[100], /* Temporary format string for sprintf() */
*tptr, /* Pointer into temporary format */
temp[1024]; /* Buffer for formatted numbers */
+ size_t templen; /* Length of "temp" */
char *s; /* Pointer to string */
int slen; /* Length of string */
int bytes; /* Total number of bytes needed */
break;
sprintf(temp, tformat, va_arg(ap, double));
+ templen = strlen(temp):
- bytes += (int)strlen(temp);
+ bytes += (int)templen;
if (bufptr)
{
- if ((bufptr + strlen(temp)) > bufend)
+ if ((bufptr + templen) > bufend)
{
- strncpy(bufptr, temp, (size_t)(bufend - bufptr));
+ strlcpy(bufptr, temp, (size_t)(bufend - bufptr));
bufptr = bufend;
}
else
{
- strcpy(bufptr, temp);
- bufptr += strlen(temp);
+ memcpy(bufptr, temp, templen + 1);
+ bufptr += templen;
}
}
break;
break;
sprintf(temp, tformat, va_arg(ap, int));
+ templen = strlen(temp):
- bytes += (int)strlen(temp);
+ bytes += (int)templen;
if (bufptr)
{
- if ((bufptr + strlen(temp)) > bufend)
+ if ((bufptr + templen) > bufend)
{
- strncpy(bufptr, temp, (size_t)(bufend - bufptr));
+ strlcpy(bufptr, temp, (size_t)(bufend - bufptr));
bufptr = bufend;
}
else
{
- strcpy(bufptr, temp);
- bufptr += strlen(temp);
+ memcpy(bufptr, temp, templen + 1);
+ bufptr += templen;
}
}
break;
break;
sprintf(temp, tformat, va_arg(ap, void *));
+ templen = strlen(temp):
- bytes += (int)strlen(temp);
+ bytes += (int)templen;
if (bufptr)
{
- if ((bufptr + strlen(temp)) > bufend)
+ if ((bufptr + templen) > bufend)
{
- strncpy(bufptr, temp, (size_t)(bufend - bufptr));
+ strlcpy(bufptr, temp, (size_t)(bufend - bufptr));
bufptr = bufend;
}
else
{
- strcpy(bufptr, temp);
- bufptr += strlen(temp);
+ memcpy(bufptr, temp, templen + 1);
+ bufptr += templen;
}
}
break;
*
* String functions for CUPS.
*
- * Copyright 2007-2011 by Apple Inc.
+ * Copyright 2007-2012 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
char * /* O - String pointer */
_cupsStrAlloc(const char *s) /* I - String */
{
+ size_t slen; /* Length of string */
_cups_sp_item_t *item, /* String pool item */
*key; /* Search key */
* Not found, so allocate a new one...
*/
- item = (_cups_sp_item_t *)calloc(1, sizeof(_cups_sp_item_t) + strlen(s));
+ slen = strlen(s);
+ item = (_cups_sp_item_t *)calloc(1, sizeof(_cups_sp_item_t) + slen);
if (!item)
{
_cupsMutexUnlock(&sp_mutex);
}
item->ref_count = 1;
- strcpy(item->str, s);
+ memcpy(item->str, s, slen + 1);
#ifdef DEBUG_GUARDS
item->guard = _CUPS_STR_GUARD;
char * /* O - New string pointer */
_cups_strdup(const char *s) /* I - String to duplicate */
{
- char *t; /* New string pointer */
+ char *t; /* New string pointer */
+ size_t slen; /* Length of string */
- if (s == NULL)
+ if (!s)
return (NULL);
- if ((t = malloc(strlen(s) + 1)) == NULL)
+ slen = strlen(s);
+ if ((t = malloc(slen + 1)) == NULL)
return (NULL);
- return (strcpy(t, s));
+ return (memcpy(t, s, slen + 1));
}
#endif /* !HAVE_STRDUP */
*
* Array test program for CUPS.
*
- * Copyright 2007-2010 by Apple Inc.
+ * Copyright 2007-2012 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
/*
* cupsArrayCount()
*/
-
+
fputs("cupsArrayCount: ", stdout);
if (cupsArrayCount(array) == 4)
puts("PASS");
* the same buffer in the first place... :)
*/
- strcpy(word, text);
+ strlcpy(word, text, sizeof(word));
/*
* Grab the next word and compare...
*
* HTTP test program for CUPS.
*
- * Copyright 2007-2011 by Apple Inc.
+ * Copyright 2007-2012 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
fputs("httpGetDateString()/httpGetDateTime(): ", stdout);
start = time(NULL);
- strcpy(buffer, httpGetDateString(start));
+ strlcpy(buffer, httpGetDateString(start), sizeof(buffer));
current = httpGetDateTime(buffer);
i = (int)(current - start);
*
* Internationalization test for CUPS.
*
- * Copyright 2007-2011 by Apple Inc.
+ * Copyright 2007-2012 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
fputs("cupsCharsetToUTF8(CUPS_ISO8859_1): ", stdout);
- strcpy(legsrc, legdest);
+ strlcpy(legsrc, legdest, sizeof(legsrc));
len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_ISO8859_1);
if (len != strlen((char *)utf8latin))
fputs("cupsCharsetToUTF8(CUPS_ISO8859_7): ", stdout);
- strcpy(legsrc, legdest);
+ strlcpy(legsrc, legdest, sizeof(legsrc));
len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_ISO8859_7);
if (len != strlen((char *)utf8greek))
fputs("cupsCharsetToUTF8(CUPS_WINDOWS_932): ", stdout);
- strcpy(legsrc, legdest);
+ strlcpy(legsrc, legdest, sizeof(legsrc));
len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_WINDOWS_932);
if (len != strlen((char *)utf8japan))
#ifndef __linux
fputs("cupsCharsetToUTF8(CUPS_EUC_JP): ", stdout);
- strcpy(legsrc, legdest);
+ strlcpy(legsrc, legdest, sizeof(legsrc));
len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_EUC_JP);
if (len != strlen((char *)utf8japan))
fputs("cupsCharsetToUTF8(CUPS_WINDOWS_950): ", stdout);
- strcpy(legsrc, legdest);
+ strlcpy(legsrc, legdest, sizeof(legsrc));
len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_WINDOWS_950);
if (len != strlen((char *)utf8taiwan))
fputs("cupsCharsetToUTF8(CUPS_EUC_TW): ", stdout);
- strcpy(legsrc, legdest);
+ strlcpy(legsrc, legdest, sizeof(legsrc));
len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_EUC_TW);
if (len != strlen((char *)utf8taiwan))
*
* PPD test program for CUPS.
*
- * Copyright 2007-2011 by Apple Inc.
+ * Copyright 2007-2012 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
if ((realsize = readlink(filename, realfile, sizeof(realfile) - 1)) < 0)
- strcpy(realfile, "Unknown");
+ strlcpy(realfile, "Unknown", sizeof(realfile));
else
realfile[realsize] = '\0';
}
if (cg->server[0] == '/')
- strcpy(cg->servername, "localhost");
+ strlcpy(cg->servername, "localhost", sizeof(cg->servername));
else
strlcpy(cg->servername, cg->server, sizeof(cg->servername));
}
value = NULL;
if (cg->server[0] == '/')
- strcpy(cg->servername, "localhost");
+ strlcpy(cg->servername, "localhost", sizeof(cg->servername));
else
strlcpy(cg->servername, cg->server, sizeof(cg->servername));
}
* Use the default "unknown" user name...
*/
- strcpy(cg->user, "unknown");
+ strlcpy(cg->user, "unknown", sizeof(cg->user));
}
}
}
}
}
else
- strcpy(uri, "ipp://localhost/");
+ strlcpy(uri, "ipp://localhost/", sizeof(uri));
if (!http)
if ((http = _cupsConnect()) == NULL)
DEBUG_printf(("2cupsGetPPD3: Local hostname=\"%s\"", localhost));
if (!_cups_strcasecmp(localhost, hostname))
- strcpy(hostname, "localhost");
+ strlcpy(hostname, "localhost", sizeof(hostname));
/*
* Get the hostname and port number we are connected to...
h->cupsImagingBBox[2] = 612.0f;
h->cupsImagingBBox[3] = 792.0f;
- strcpy(h->cupsPageSizeName, "Letter");
+ strlcpy(h->cupsPageSizeName, "Letter", sizeof(h->cupsPageSizeName));
#ifdef __APPLE__
/*
* Verify that translations in the .po file have the same number and type of
* printf-style format strings.
*
- * Copyright 2007-2010 by Apple Inc.
+ * Copyright 2007-2012 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
}
if (*s)
- strcpy(bufptr, "...");
+ memcpy(bufptr, "...", 4);
else
*bufptr = '\0';
* Append to current string...
*/
+ size_t ptrlen = strlen(ptr); /* Length of string */
+
length = (int)strlen(msgstr ? msgstr : msgid);
if ((temp = realloc(msgstr ? msgstr : msgid,
- length + strlen(ptr) + 1)) == NULL)
+ length + ptrlen + 1)) == NULL)
{
free(msgid);
if (msgstr)
msgstr = temp;
- strcpy(msgstr + length, ptr);
+ memcpy(msgstr + length, ptr, ptrlen + 1);
}
else
{
msgid = temp;
- strcpy(msgid + length, ptr);
+ memcpy(msgid + length, ptr, ptrlen + 1);
}
}
else if (!strncmp(s, "msgstr", 6) && msgid)
*
* D-Bus notifier for CUPS.
*
- * Copyright 2008-2011 by Apple Inc.
+ * Copyright 2008-2012 by Apple Inc.
* Copyright (C) 2011 Red Hat, Inc.
* Copyright (C) 2007 Tim Waugh <twaugh@redhat.com>
* Copyright 1997-2005 by Easy Software Products.
if (i)
*p++ = ',';
- strcpy(p, ippGetString(attr, i, NULL));
+ strlcpy(p, ippGetString(attr, i, NULL),
+ reasons_length - (p - printer_reasons));
p += strlen(p);
}
if (!dbus_message_iter_append_string(&iter, &printer_reasons))
if (i)
*p++ = ',';
- strcpy(p, ippGetString(attr, i, NULL));
+ strlcpy(p, ippGetString(attr, i, NULL),
+ reasons_length - (p - job_reasons));
p += strlen(p);
}
if (!dbus_message_iter_append_string(&iter, &job_reasons))
while (isspace(*ptr))
ptr ++;
- strcpy(program, ptr);
+ strlcpy(program, ptr, sizeof(program));
}
else
{
if ((baseptr = strrchr(basedir, '/')) != NULL)
*baseptr = '\0';
else
- strcpy(basedir, ".");
+ strlcpy(basedir, ".", sizeof(basedir));
// Find the po file...
pofilename[0] = '\0';
if ((baseptr = strrchr(basedir, '/')) != NULL)
*baseptr = '\0';
else
- strcpy(basedir, ".");
+ strlcpy(basedir, ".", sizeof(basedir));
// Find the include file...
if (find_include(inctemp, basedir, incname, sizeof(incname)))
//
// Shared string class for the CUPS PPD Compiler.
//
-// Copyright 2007-2009 by Apple Inc.
+// Copyright 2007-2012 by Apple Inc.
// Copyright 2002-2005 by Easy Software Products.
//
// These coded instructions, statements, and computer programs are the
if (v)
{
- value = new char[strlen(v) + 1];
- strcpy(value, v);
+ size_t vlen = strlen(v);
+
+ value = new char[vlen + 1];
+ memcpy(value, v, vlen + 1);
}
else
value = 0;
if (sscanf(authorization, "%255s", scheme) != 1)
- strcpy(scheme, "UNKNOWN");
+ strlcpy(scheme, "UNKNOWN", sizeof(scheme));
cupsdLogMessage(CUPSD_LOG_ERROR,
"[Client %d] Bad authentication data \"%s ...\"",
cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to get local address - %s",
strerror(errno));
- strcpy(con->servername, "localhost");
+ strlcpy(con->servername, "localhost", sizeof(con->servername));
con->serverport = LocalPort;
}
#ifdef AF_LOCAL
else if (_httpAddrFamily(&temp) == AF_LOCAL)
{
- strcpy(con->servername, "localhost");
+ strlcpy(con->servername, "localhost", sizeof(con->servername));
con->serverport = LocalPort;
}
#endif /* AF_LOCAL */
* con->uri are HTTP_MAX_URI bytes in size...
*/
- strcpy(con->uri, resource);
+ strlcpy(con->uri, resource, sizeof(con->uri));
}
/*
else
{
if (type == NULL)
- strcpy(line, "text/plain");
+ strlcpy(line, "text/plain", sizeof(line));
else
snprintf(line, sizeof(line), "%s/%s", type->super, type->type);
type = mimeFileType(MimeDatabase, filename, NULL, NULL);
if (type == NULL)
- strcpy(line, "text/plain");
+ strlcpy(line, "text/plain", sizeof(line));
else
snprintf(line, sizeof(line), "%s/%s", type->super, type->type);
* the POSIX locale...
*/
- strcpy(lang, "LANG=C");
+ strlcpy(lang, "LANG=C", sizeof(lang));
break;
case 2 :
else if (con->language)
snprintf(lang, sizeof(lang), "LANG=%s.UTF8", con->language->language);
else
- strcpy(lang, "LANG=C");
+ strlcpy(lang, "LANG=C", sizeof(lang));
- strcpy(remote_addr, "REMOTE_ADDR=");
+ strlcpy(remote_addr, "REMOTE_ADDR=", sizeof(remote_addr));
httpAddrString(con->http.hostaddr, remote_addr + 12,
sizeof(remote_addr) - 12);
return;
a->namelen = namelen;
- strcpy(a->name, name); /* OK since a->name is allocated */
+ memcpy(a->name, name, namelen + 1); /* OK since a->name is allocated */
cupsArrayAdd(aliases, a);
}
device_id[0] = '\0';
product[0] = '\0';
psversion[0] = '\0';
- strcpy(type_str, "postscript");
+ strlcpy(type_str, "postscript", sizeof(type_str));
if (sscanf(line, "\"%511[^\"]\"%127s%*[ \t]\"%127[^\"]\""
"%*[ \t]\"%127[^\"]\"%*[ \t]\"%255[^\"]\""
manufacturer[0] = '\0';
device_id[0] = '\0';
lang_encoding[0] = '\0';
- strcpy(lang_version, "en");
+ strlcpy(lang_version, "en", sizeof(lang_version));
model_number = 0;
install_group = 0;
type = PPD_TYPE_POSTSCRIPT;
cupsCharsetToUTF8((cups_utf8_t *)make_model, nick_name,
sizeof(make_model), _ppdGetEncoding(lang_encoding));
else
- strcpy(make_model, model_name);
+ strlcpy(make_model, model_name, sizeof(make_model));
while (isspace(make_model[0] & 255))
_cups_strcpy(make_model, make_model + 1);
if (*ptr && ptr > manufacturer)
*ptr = '\0';
else
- strcpy(manufacturer, "Other");
+ strlcpy(manufacturer, "Other", sizeof(manufacturer));
}
else if (!_cups_strncasecmp(manufacturer, "LHAG", 4) ||
!_cups_strncasecmp(manufacturer, "linotype", 8))
- strcpy(manufacturer, "LHAG");
+ strlcpy(manufacturer, "LHAG", sizeof(manufacturer));
else if (!_cups_strncasecmp(manufacturer, "Hewlett", 7))
- strcpy(manufacturer, "HP");
+ strlcpy(manufacturer, "HP", sizeof(manufacturer));
/*
* Fix the lang_version as needed...
* Unknown language; use "xx"...
*/
- strcpy(lang_version, "xx");
+ strlcpy(lang_version, "xx", sizeof(lang_version));
}
/*
* See if this file has been scanned before...
*/
- strcpy(key.record.filename, name);
- strcpy(key.record.name, name);
+ strlcpy(key.record.filename, name, sizeof(key.record.filename));
+ strlcpy(key.record.name, name, sizeof(key.record.name));
ppd = (ppd_info_t *)cupsArrayFind(PPDsByName, &key);
if (getpeername(0, (struct sockaddr *)&hostaddr, &hostlen))
{
syslog(LOG_WARNING, "Unable to get client address - %s", strerror(errno));
- strcpy(hostname, "unknown");
+ strlcpy(hostname, "unknown", sizeof(hostname));
}
else
{
break;
}
- strcpy(filename, control);
+ strlcpy(filename, control, sizeof(filename));
}
break;
break;
}
- strcpy(filename, temp[num_data]);
+ strlcpy(filename, temp[num_data], sizeof(filename));
num_data ++;
break;
{
syslog(LOG_WARNING, "No username specified by client! "
"Using \"anonymous\"...");
- strcpy(user, "anonymous");
+ strlcpy(user, "anonymous", sizeof(user));
}
/*
*/
if (jobstate == IPP_JOB_PROCESSING)
- strcpy(rankstr, "active");
+ strlcpy(rankstr, "active", sizeof(rankstr));
else
{
snprintf(rankstr, sizeof(rankstr), "%d%s", rank, ranks[rank % 10]);
if (sptr > s)
*sptr++ = ' ';
- strcpy(sptr, option->name);
+ strlcpy(sptr, option->name, bytes - (sptr - s));
sptr += strlen(sptr);
*sptr++ = '=';
* Auto-type it!
*/
- strcpy(super, "application");
- strcpy(type, "octet-stream");
+ strlcpy(super, "application", sizeof(super));
+ strlcpy(type, "octet-stream", sizeof(type));
}
if (!strcmp(super, "application") && !strcmp(type, "octet-stream"))
if ((attr = ippFindAttribute(con->request, "printer-state-message",
IPP_TAG_TEXT)) == NULL)
- strcpy(printer->state_message, "Rejecting Jobs");
+ strlcpy(printer->state_message, "Rejecting Jobs",
+ sizeof(printer->state_message));
else
strlcpy(printer->state_message, attr->values[0].string.text,
sizeof(printer->state_message));
* No document format attribute? Auto-type it!
*/
- strcpy(super, "application");
- strcpy(type, "octet-stream");
+ strlcpy(super, "application", sizeof(super));
+ strlcpy(type, "octet-stream", sizeof(type));
}
if (!strcmp(super, "application") && !strcmp(type, "octet-stream"))
if ((attr = ippFindAttribute(con->request, "printer-state-message",
IPP_TAG_TEXT)) == NULL)
- strcpy(printer->state_message, "Paused");
+ strlcpy(printer->state_message, "Paused", sizeof(printer->state_message));
else
{
strlcpy(printer->state_message, attr->values[0].string.text,
IPP_TAG_LANGUAGE);
#ifdef __APPLE__
- strcpy(apple_language, "APPLE_LANGUAGE=");
+ strlcpy(apple_language, "APPLE_LANGUAGE=", sizeof(apple_language));
_cupsAppleLanguage(attr->values[0].string.text,
apple_language + 15, sizeof(apple_language) - 15);
#endif /* __APPLE__ */
* the POSIX locale...
*/
- strcpy(lang, "LANG=C");
+ strlcpy(lang, "LANG=C", sizeof(lang));
break;
case 2 :
* All of these strcpy's are safe because we allocated the psr string...
*/
- strcpy(printer_state_reasons, "PRINTER_STATE_REASONS=");
+ strlcpy(printer_state_reasons, "PRINTER_STATE_REASONS=", psrlen);
for (psrptr = printer_state_reasons + 22, i = 0;
i < job->printer->num_reasons;
i ++)
{
if (i)
*psrptr++ = ',';
- strcpy(psrptr, job->printer->reasons[i]);
+ strlcpy(psrptr, job->printer->reasons[i],
+ psrlen - (psrptr - printer_state_reasons));
psrptr += strlen(psrptr);
}
}
for (i = num_pwgppds, pwgppd = pwgppds; i > 0; i --, pwgppd ++)
{
*optptr++ = ' ';
- strcpy(optptr, pwgppd->name);
+ strlcpy(optptr, pwgppd->name, optlength - (optptr - options));
optptr += strlen(optptr);
*optptr++ = '=';
- strcpy(optptr, pwgppd->value);
+ strlcpy(optptr, pwgppd->value, optlength - (optptr - options));
optptr += strlen(optptr);
}
*
* Log file routines for the CUPS scheduler.
*
- * Copyright 2007-2011 by Apple Inc.
+ * Copyright 2007-2012 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
cupsFileClose(*lf);
- strcpy(backname, filename);
+ strlcpy(backname, filename, sizeof(backname));
strlcat(backname, ".O", sizeof(backname));
unlink(backname);
if ((temp = malloc(sizeof(cupsd_joblog_t) + strlen(log_line))) != NULL)
{
temp->time = time(NULL);
- strcpy(temp->message, log_line);
+ strlcpy(temp->message, log_line, sizeof(temp->message));
}
if (!job->history)
if (!PageLogFormat)
return (1);
- strcpy(number, "1");
+ strlcpy(number, "1", sizeof(number));
copies = 1;
sscanf(page, "%255s%d", number, &copies);
*
* MIME database file routines for CUPS.
*
- * Copyright 2007-2011 by Apple Inc.
+ * Copyright 2007-2012 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
filter ? filter->dst->super : "???",
filter ? filter->cost : -1,
filter ? CUPS_LLCAST filter->maxsize : CUPS_LLCAST -1));
-
+
if (!mime || !filter)
return;
if (!mime_add_fcache(filtercache, filter, filterpath))
{
DEBUG_printf(("mime_load_convs: Filter %s not found in %s.", filter,
- filterpath));
+ filterpath));
_mimeError(mime, "Filter \"%s\" not found.", filter);
continue;
}
* Force * / * to be "application/octet-stream"...
*/
- strcpy(super, "application");
- strcpy(type, "octet-stream");
+ strlcpy(super, "application", sizeof(super));
+ strlcpy(type, "octet-stream", sizeof(type));
}
/*
*
* MIME typing routines for CUPS.
*
- * Copyright 2007-2011 by Apple Inc.
+ * Copyright 2007-2012 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
case MIME_MAGIC_MATCH :
if (length[0] > (sizeof(temp->value.matchv) - 1))
return (-1);
- strcpy(temp->value.matchv, value[0]);
+ strlcpy(temp->value.matchv, value[0], sizeof(temp->value.matchv));
break;
case MIME_MAGIC_ASCII :
case MIME_MAGIC_PRINTABLE :
if (length[0] > (sizeof(temp->value.localev) - 1))
return (-1);
- strcpy(temp->value.localev, value[0]);
+ strlcpy(temp->value.localev, value[0], sizeof(temp->value.localev));
break;
case MIME_MAGIC_CONTAINS :
temp->offset = strtol(value[0], NULL, 0);
if (!_cups_strncasecmp(option, "Custom", 6) && !_cups_strcasecmp(choice, "True"))
{
_cups_strcpy(option, option + 6);
- strcpy(choice, "Custom");
+ strlcpy(choice, "Custom", sizeof(choice));
}
if ((o = ppdFindOption(ppd, option)) == NULL)
if (!_cups_strncasecmp(c->option1, "Custom", 6) &&
!_cups_strcasecmp(c->choice1, "True"))
{
- strcpy(option, c->option1 + 6);
- strcpy(choice, "Custom");
+ strlcpy(option, c->option1 + 6, sizeof(option));
+ strlcpy(choice, "Custom", sizeof(choice));
}
else
{
- strcpy(option, c->option1);
- strcpy(choice, c->choice1);
+ strlcpy(option, c->option1, sizeof(option));
+ strlcpy(choice, c->choice1, sizeof(choice));
}
if ((o = ppdFindOption(ppd, option)) == NULL)
if (!_cups_strncasecmp(c->option2, "Custom", 6) &&
!_cups_strcasecmp(c->choice2, "True"))
{
- strcpy(option, c->option2 + 6);
- strcpy(choice, "Custom");
+ strlcpy(option, c->option2 + 6, sizeof(option));
+ strlcpy(choice, "Custom", sizeof(choice));
}
else
{
- strcpy(option, c->option2);
- strcpy(choice, c->choice2);
+ strlcpy(option, c->option2, sizeof(option));
+ strlcpy(choice, c->choice2, sizeof(choice));
}
if ((o = ppdFindOption(ppd, option)) == NULL)
*/
if (!strftime(date, sizeof(date), "%b %d %H:%M", jobdate))
- strcpy(date, "Unknown");
+ strlcpy(date, "Unknown", sizeof(date));
_cupsLangPrintf(stdout, "%s;%s;%d;%s;%s",
temp, username ? username : "unknown",
else
{
if (!strftime(date, sizeof(date), "%c", jobdate))
- strcpy(date, "Unknown");
+ strlcpy(date, "Unknown", sizeof(date));
if (ranking)
_cupsLangPrintf(stdout, "%3d %-21s %-13s %8.0f %s",