/*
* Line Printer Daemon backend for CUPS.
*
- * Copyright © 2007-2016 by Apple Inc.
+ * Copyright © 2007-2019 by Apple Inc.
* Copyright © 1997-2007 by Easy Software Products, all rights reserved.
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more
static int cups_rresvport(int *port, int family);
static int lpd_command(int lpd_fd, char *format, ...);
-static int lpd_queue(const char *hostname, http_addrlist_t *addrlist,
- const char *printer, int print_fd, int snmp_fd,
- int mode, const char *user, const char *title,
- int copies, int banner, int format, int order,
- int reserve, int manual_copies, int timeout,
- int contimeout, const char *orighost);
+static int lpd_queue(const char *hostname, http_addrlist_t *addrlist, const char *printer, int print_fd, int snmp_fd, int mode, const char *user, const char *title, int copies, int banner, int format, int order, int reserve, int manual_copies, int timeout, int contimeout, const char *orighost) _CUPS_NONNULL((1,2,3,7,8,17));
static ssize_t lpd_write(int lpd_fd, char *buffer, size_t length);
static void sigterm_handler(int sig);
/*
* CGI support library definitions for CUPS.
*
- * Copyright 2007-2010 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
+ * Copyright © 2007-2019 by Apple Inc.
+ * Copyright © 1997-2006 by Easy Software Products.
*
- * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+ * Licensed under Apache License v2.0. See the file "LICENSE" for more
+ * information.
*/
#ifndef _CUPS_CGI_H_
extern char *cgiFormEncode(char *dst, const char *src,
size_t dstsize);
extern void cgiFreeSearch(void *search);
-extern const char *cgiGetArray(const char *name, int element);
+extern char *cgiGetArray(const char *name, int element);
extern void cgiGetAttributes(ipp_t *request, const char *tmpl);
extern const char *cgiGetCookie(const char *name);
extern const cgi_file_t *cgiGetFile(void);
extern cups_array_t *cgiGetIPPObjects(ipp_t *response, void *search);
extern int cgiGetSize(const char *name);
extern char *cgiGetTemplateDir(void);
-extern const char *cgiGetVariable(const char *name);
+extern char *cgiGetVariable(const char *name);
extern int cgiInitialize(void);
extern int cgiIsPOST(void);
extern void cgiMoveJobs(http_t *http, const char *dest, int job_id);
/*
* Online help index routines for CUPS.
*
- * Copyright 2007-2017 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products.
+ * Copyright © 2007-2019 by Apple Inc.
+ * Copyright © 1997-2007 by Easy Software Products.
*
- * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+ * Licensed under Apache License v2.0. See the file "LICENSE" for more
+ * information.
*/
/*
while (isspace(*ptr & 255))
ptr ++;
}
+ else
+ section[0] = '\0';
if (*ptr != '\"')
break;
n->filename = strdup(filename);
n->anchor = anchor ? strdup(anchor) : NULL;
- n->section = *section ? strdup(section) : NULL;
+ n->section = (section && *section) ? strdup(section) : NULL;
n->text = strdup(text);
n->mtime = mtime;
n->offset = offset;
* Copyright © 2007-2019 by Apple Inc.
* Copyright © 1997-2005 by Easy Software Products.
*
- * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+ * Licensed under Apache License v2.0. See the file "LICENSE" for more
+ * information.
*/
/*
return (0);
if (*val == '\0')
+ {
+ free((void *)val);
return (0); /* Can't be blank, either! */
+ }
+
+ free((void *)val);
}
return (1);
* 'cgiGetArray()' - Get an element from a form array.
*/
-const char * /* O - Element value or NULL */
+char * /* O - Element value or NULL */
cgiGetArray(const char *name, /* I - Name of array variable */
int element) /* I - Element number (0 to N) */
{
* array of values, returns the last element.
*/
-const char * /* O - Value of variable */
+char * /* O - Value of variable */
cgiGetVariable(const char *name) /* I - Name of variable */
{
const _cgi_var_t *var; /* Returned variable */
else
fputs("DEBUG: " CUPS_SID " form variable is not present.\n", stderr);
+ free((void *)cups_sid_form);
+
cgiClearVariables();
+
return (0);
}
else
+ {
+ free((void *)cups_sid_form);
+
return (1);
+ }
}
else
return (0);
if (line[0])
cgiSetArray(name, atoi(ptr) - 1, line);
}
- else if (cgiGetVariable(name))
+ else if ((ptr = cgiGetVariable(name)) != NULL)
{
/*
* Add another element in the array...
*/
+ free(ptr);
cgiSetArray(name, cgiGetSize(name), line);
}
else
char *s, /* Pointer to current form string */
ch, /* Temporary character */
name[255], /* Name of form variable */
- value[65536]; /* Variable value */
+ value[65536], /* Variable value */
+ *temp; /* Temporary pointer */
/*
if (value[0])
cgiSetArray(name, atoi(s) - 1, value);
}
- else if (cgiGetVariable(name) != NULL)
+ else if ((temp = cgiGetVariable(name)) != NULL)
+ {
+ free(temp);
cgiSetArray(name, cgiGetSize(name), value);
+ }
else
cgiSetVariable(name, value);
}
//
// PPD file compiler definitions for the CUPS PPD Compiler.
//
-// Copyright 2007-2018 by Apple Inc.
-// Copyright 2002-2006 by Easy Software Products.
+// Copyright © 2007-2019 by Apple Inc.
+// Copyright © 2002-2006 by Easy Software Products.
//
-// Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
//
//
_cupsLangPrintf(stderr,
_("ppdc: No message catalog provided for locale "
"%s."), locale->value);
+ delete locatalog;
continue;
}
return (1);
}
- if ((fp = get_file(resource, request_id, "drv", filename, sizeof(filename),
- &pc_file_name)) == NULL)
+ if ((fp = get_file(resource, request_id, "drv", filename, sizeof(filename), &pc_file_name)) == NULL || !pc_file_name)
return (1);
src = new ppdcSource(filename, fp);
cupsdClosePipe(filterfds[slot]);
for (i = 6; i < argc; i ++)
- if (argv[i])
- free(argv[i]);
-
+ free(argv[i]);
free(argv);
if (printer_state_reasons)
if (argv)
{
for (i = 6; i < argc; i ++)
- if (argv[i])
- free(argv[i]);
+ free(argv[i]);
+
+ free(argv);
}
if (printer_state_reasons)
strlcpy(filename, ConfigurationFile, len);
if ((slash = strrchr(filename, '/')) == NULL)
{
+ free(filename);
_cupsLangPrintf(stderr,
_("cupsd: Unable to get path to "
"cups-files.conf file."));
/*
* MIME typing routines for CUPS.
*
- * Copyright 2007-2016 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products, all rights reserved.
+ * Copyright © 2007-2019 by Apple Inc.
+ * Copyright © 1997-2006 by Easy Software Products, all rights reserved.
*
- * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+ * Licensed under Apache License v2.0. See the file "LICENSE" for more
+ * information.
*/
/*
case MIME_MAGIC_STRING :
case MIME_MAGIC_ISTRING :
temp->offset = strtol(value[0], NULL, 0);
- if ((size_t)length[1] > sizeof(temp->value.stringv))
+ if (num_values < 2 || (size_t)length[1] > sizeof(temp->value.stringv))
return (-1);
temp->length = 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 (length[1] == 1)
+ if (num_values < 2)
+ return (-1);
+ else if (length[1] == 1)
temp->value.charv = (unsigned char)value[1][0];
else
temp->value.charv = (unsigned char)strtol(value[1], NULL, 0);
case MIME_MAGIC_CONTAINS :
temp->offset = strtol(value[0], NULL, 0);
temp->region = strtol(value[1], NULL, 0);
- if ((size_t)length[2] > sizeof(temp->value.stringv))
+ if (num_values < 3 || (size_t)length[2] > sizeof(temp->value.stringv))
return (-1);
temp->length = length[2];
memcpy(temp->value.stringv, value[2], (size_t)length[2]);
hostname[HTTP_MAX_HOST];
/* Hostname */
int port; /* Port number */
- const char *encoding; /* Content-Encoding value */
static const char * const http_states[] =
{ /* Strings for logging HTTP method */
"WAITING",
* Handle new transfers...
*/
- encoding = httpGetContentEncoding(client->http);
-
switch (client->operation)
{
case HTTP_STATE_OPTIONS :
* Value is an extended, case-sensitive POSIX regular expression...
*/
+ void *adata; /* Pointer to octetString data */
+ int adatalen; /* Length of octetString */
regex_t re; /* Regular expression */
if ((i = regcomp(&re, value, REG_EXTENDED | REG_NOSUB)) != 0)
for (i = 0; i < count; i ++)
{
- void *data; /* Pointer to octetString data */
- int datalen; /* Length of octetString */
-
- if ((data = ippGetOctetString(attr, i, &datalen)) == NULL || datalen >= (int)sizeof(temp))
+ if ((adata = ippGetOctetString(attr, i, &adatalen)) == NULL || adatalen >= (int)sizeof(temp))
{
match = 0;
break;
}
- memcpy(temp, data, (size_t)datalen);
- temp[datalen] = '\0';
+ memcpy(temp, adata, (size_t)adatalen);
+ temp[adatalen] = '\0';
if (!regexec(&re, temp, 0, NULL, 0))
{
{
for (i = 0; i < count; i ++)
{
- int adatalen;
- void *adata = ippGetOctetString(attr, i, &adatalen);
-
+ adata = ippGetOctetString(attr, i, &adatalen);
copy_hex_string(temp, adata, adatalen, sizeof(temp));
add_stringf(data->errors, "GOT: %s=\"%s\"", name, temp);
}