|
|
d35507 |
diff -up cups-filters-1.0.35/utils/cups-browsed.c.covscan cups-filters-1.0.35/utils/cups-browsed.c
|
|
|
d35507 |
--- cups-filters-1.0.35/utils/cups-browsed.c.covscan 2019-02-27 17:52:37.000000000 +0100
|
|
|
d35507 |
+++ cups-filters-1.0.35/utils/cups-browsed.c 2019-03-18 16:01:49.345858931 +0100
|
|
|
d35507 |
@@ -1934,7 +1934,10 @@ is_disabled(const char *printer, const c
|
|
|
d35507 |
pstate = (ipp_pstate_t)ippGetInteger(attr, 0);
|
|
|
d35507 |
else if (!strcmp(ippGetName(attr), "printer-state-message") &&
|
|
|
d35507 |
ippGetValueTag(attr) == IPP_TAG_TEXT) {
|
|
|
d35507 |
- free(pstatemsg);
|
|
|
d35507 |
+ if (pstatemsg != NULL) {
|
|
|
d35507 |
+ free(pstatemsg);
|
|
|
d35507 |
+ pstatemsg = NULL;
|
|
|
d35507 |
+ }
|
|
|
d35507 |
p = ippGetString(attr, 0, NULL);
|
|
|
d35507 |
if (p != NULL) pstatemsg = strdup(p);
|
|
|
d35507 |
}
|
|
|
d35507 |
@@ -1951,16 +1954,22 @@ is_disabled(const char *printer, const c
|
|
|
d35507 |
case IPP_PRINTER_IDLE:
|
|
|
d35507 |
case IPP_PRINTER_PROCESSING:
|
|
|
d35507 |
ippDelete(response);
|
|
|
d35507 |
- free(pstatemsg);
|
|
|
d35507 |
+ if (pstatemsg != NULL) {
|
|
|
d35507 |
+ free(pstatemsg);
|
|
|
d35507 |
+ pstatemsg = NULL;
|
|
|
d35507 |
+ }
|
|
|
d35507 |
return NULL;
|
|
|
d35507 |
case IPP_PRINTER_STOPPED:
|
|
|
d35507 |
ippDelete(response);
|
|
|
d35507 |
if (reason == NULL)
|
|
|
d35507 |
return pstatemsg;
|
|
|
d35507 |
- else if (strcasestr(pstatemsg, reason) != NULL)
|
|
|
d35507 |
+ else if (pstatemsg != NULL && (strcasestr(pstatemsg, reason) != NULL))
|
|
|
d35507 |
return pstatemsg;
|
|
|
d35507 |
else {
|
|
|
d35507 |
- free(pstatemsg);
|
|
|
d35507 |
+ if (pstatemsg != NULL) {
|
|
|
d35507 |
+ free(pstatemsg);
|
|
|
d35507 |
+ pstatemsg = NULL;
|
|
|
d35507 |
+ }
|
|
|
d35507 |
return NULL;
|
|
|
d35507 |
}
|
|
|
d35507 |
}
|
|
|
d35507 |
@@ -1969,12 +1978,18 @@ is_disabled(const char *printer, const c
|
|
|
d35507 |
debug_printf("No information regarding enabled/disabled found about the requested printer '%s'\n",
|
|
|
d35507 |
printer);
|
|
|
d35507 |
ippDelete(response);
|
|
|
d35507 |
- free(pstatemsg);
|
|
|
d35507 |
+ if (pstatemsg != NULL) {
|
|
|
d35507 |
+ free(pstatemsg);
|
|
|
d35507 |
+ pstatemsg = NULL;
|
|
|
d35507 |
+ }
|
|
|
d35507 |
return NULL;
|
|
|
d35507 |
}
|
|
|
d35507 |
debug_printf("ERROR: Request for printer info failed: %s\n",
|
|
|
d35507 |
cupsLastErrorString());
|
|
|
d35507 |
- free(pstatemsg);
|
|
|
d35507 |
+ if (pstatemsg != NULL) {
|
|
|
d35507 |
+ free(pstatemsg);
|
|
|
d35507 |
+ pstatemsg = NULL;
|
|
|
d35507 |
+ }
|
|
|
d35507 |
return NULL;
|
|
|
d35507 |
}
|
|
|
d35507 |
|
|
|
d35507 |
@@ -3421,6 +3436,8 @@ gboolean handle_cups_queues(gpointer unu
|
|
|
d35507 |
} else {
|
|
|
d35507 |
/* Device URI: ipp(s)://<remote host>:631/printers/<remote queue> */
|
|
|
d35507 |
strncpy(device_uri, p->uri, sizeof(device_uri));
|
|
|
d35507 |
+ if (strlen(p->uri) > HTTP_MAX_URI-1)
|
|
|
d35507 |
+ device_uri[HTTP_MAX_URI-1] = '\0';
|
|
|
d35507 |
debug_printf("Print queue %s is for an IPP network printer, or we do not get notifications from CUPS, using direct device URI %s\n",
|
|
|
d35507 |
p->name, device_uri);
|
|
|
d35507 |
}
|
|
|
d35507 |
@@ -3529,6 +3546,8 @@ gboolean handle_cups_queues(gpointer unu
|
|
|
d35507 |
} else if (!strncmp(line, "*Default", 8)) {
|
|
|
d35507 |
cont_line_read = 0;
|
|
|
d35507 |
strncpy(keyword, line + 8, sizeof(keyword));
|
|
|
d35507 |
+ if ((strlen(line) + 8) > 1023)
|
|
|
d35507 |
+ keyword[1023] = '\0';
|
|
|
d35507 |
for (keyptr = keyword; *keyptr; keyptr ++)
|
|
|
d35507 |
if (*keyptr == ':' || isspace(*keyptr & 255))
|
|
|
d35507 |
break;
|
|
|
d35507 |
@@ -5871,7 +5890,7 @@ read_configuration (const char *filename
|
|
|
d35507 |
in the configuration file is used. */
|
|
|
d35507 |
while ((i < cupsArrayCount(command_line_config) &&
|
|
|
d35507 |
(value = cupsArrayIndex(command_line_config, i++)) &&
|
|
|
d35507 |
- strncpy(line, value, sizeof(line))) ||
|
|
|
d35507 |
+ strncpy(line, value, sizeof(line)) && ((strlen(value) > HTTP_MAX_BUFFER-1)? line[HTTP_MAX_BUFFER-1] = '\0': 1)) ||
|
|
|
d35507 |
cupsFileGetConf(fp, line, sizeof(line), &value, &linenum)) {
|
|
|
d35507 |
if (linenum < 0) {
|
|
|
d35507 |
/* We are still reading options from the command line ("-o ..."),
|
|
|
d35507 |
@@ -6098,6 +6117,7 @@ read_configuration (const char *filename
|
|
|
d35507 |
if (filter->cregexp)
|
|
|
d35507 |
regfree(filter->cregexp);
|
|
|
d35507 |
free(filter);
|
|
|
d35507 |
+ filter = NULL;
|
|
|
d35507 |
}
|
|
|
d35507 |
} else if ((!strcasecmp(line, "BrowseInterval") || !strcasecmp(line, "BrowseTimeout")) && value) {
|
|
|
d35507 |
int t = atoi(value);
|
|
|
d35507 |
@@ -6113,7 +6133,7 @@ read_configuration (const char *filename
|
|
|
d35507 |
debug_printf("Invalid %s value: %d\n",
|
|
|
d35507 |
line, t);
|
|
|
d35507 |
} else if (!strcasecmp(line, "DomainSocket") && value) {
|
|
|
d35507 |
- if (value[0] != '\0')
|
|
|
d35507 |
+ if (DomainSocket == NULL && value[0] != '\0')
|
|
|
d35507 |
DomainSocket = strdup(value);
|
|
|
d35507 |
} else if ((!strcasecmp(line, "HttpLocalTimeout") || !strcasecmp(line, "HttpRemoteTimeout")) && value) {
|
|
|
d35507 |
int t = atoi(value);
|
|
|
d35507 |
@@ -6168,7 +6188,7 @@ read_configuration (const char *filename
|
|
|
d35507 |
else if (!strncasecmp(value, "QueueOnServers", 14))
|
|
|
d35507 |
LoadBalancingType = QUEUE_ON_SERVERS;
|
|
|
d35507 |
} else if (!strcasecmp(line, "DefaultOptions") && value) {
|
|
|
d35507 |
- if (strlen(value) > 0)
|
|
|
d35507 |
+ if (DefaultOptions == NULL && strlen(value) > 0)
|
|
|
d35507 |
DefaultOptions = strdup(value);
|
|
|
d35507 |
} else if (!strcasecmp(line, "AutoShutdown") && value) {
|
|
|
d35507 |
char *p, *saveptr;
|
|
|
d35507 |
@@ -6537,6 +6557,8 @@ int main(int argc, char*argv[]) {
|
|
|
d35507 |
daemon, not with remote ones. */
|
|
|
d35507 |
if (getenv("CUPS_SERVER") != NULL) {
|
|
|
d35507 |
strncpy(local_server_str, getenv("CUPS_SERVER"), sizeof(local_server_str));
|
|
|
d35507 |
+ if (strlen(getenv("CUPS_SERVER")) > 1023)
|
|
|
d35507 |
+ local_server_str[1023] = '\0';
|
|
|
d35507 |
} else {
|
|
|
d35507 |
#ifdef CUPS_DEFAULT_DOMAINSOCKET
|
|
|
d35507 |
if (DomainSocket == NULL)
|
|
|
d35507 |
@@ -6876,6 +6898,11 @@ fail:
|
|
|
d35507 |
/* Close log file if we have one */
|
|
|
d35507 |
if (debug_logfile == 1)
|
|
|
d35507 |
stop_debug_logging();
|
|
|
d35507 |
+
|
|
|
d35507 |
+ if (DefaultOptions != NULL)
|
|
|
d35507 |
+ free(DefaultOptions);
|
|
|
d35507 |
+ if (DomainSocket != NULL)
|
|
|
d35507 |
+ free(DomainSocket);
|
|
|
d35507 |
|
|
|
d35507 |
return ret;
|
|
|
d35507 |
|