From 26bf943ed148fd42c9c338d5b8a84afe53c2bfcf Mon Sep 17 00:00:00 2001 From: Zdenek Dohnal Date: Fri, 21 Sep 2018 12:09:31 +0200 Subject: [PATCH 1/6] covscan fixes from upstream --- cups-filters-covscan.patch | 678 +++++++++++++++++++++++++++++++++++++ cups-filters.spec | 8 +- 2 files changed, 685 insertions(+), 1 deletion(-) create mode 100644 cups-filters-covscan.patch diff --git a/cups-filters-covscan.patch b/cups-filters-covscan.patch new file mode 100644 index 0000000..9a225c3 --- /dev/null +++ b/cups-filters-covscan.patch @@ -0,0 +1,678 @@ +diff --git a/backend/beh.c b/backend/beh.c +index 9ba6613..7514e33 100644 +--- a/backend/beh.c ++++ b/backend/beh.c +@@ -223,6 +223,8 @@ call_backend(char *uri, /* I - URI of final destination */ + */ + + strncpy(scheme, uri, sizeof(scheme)); ++ if (strlen(uri) > 1023) ++ scheme[1023] = '\0'; + if ((ptr = strchr(scheme, ':')) != NULL) + *ptr = '\0'; + +diff --git a/backend/implicitclass.c b/backend/implicitclass.c +index 3ce4d10..1593191 100644 +--- a/backend/implicitclass.c ++++ b/backend/implicitclass.c +@@ -104,6 +104,8 @@ main(int argc, /* I - Number of command-line args */ + } + ptr1 ++; + strncpy(queue_name, ptr1, sizeof(queue_name)); ++ if (strlen(ptr1) > 1023) ++ queue_name[1023] = '\0'; + httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, + "localhost", ippPort(), "/printers/%s", queue_name); + job_id = argv[1]; +@@ -162,6 +164,8 @@ main(int argc, /* I - Number of command-line args */ + /* Read destination host name (or message) and check whether it is + complete (second double quote) */ + strncpy(dest_host, ptr1, sizeof(dest_host)); ++ if (strlen(ptr1) > 1023) ++ dest_host[1023] = '\0'; + ptr1 = dest_host; + if ((ptr2 = strchr(ptr1, '"')) != NULL) { + *ptr2 = '\0'; +diff --git a/cupsfilters/colormanager.c b/cupsfilters/colormanager.c +index 70074a3..a4a929d 100644 +--- a/cupsfilters/colormanager.c ++++ b/cupsfilters/colormanager.c +@@ -272,6 +272,9 @@ _get_colord_profile(const char *printer_name, /* Dest name */ + free(qualifier); + } + ++ if (icc_profile != NULL) ++ free(icc_profile); ++ + return is_profile_set; + + } +@@ -325,8 +328,11 @@ _get_ppd_icc_fallback (ppd_file_t *ppd, char **qualifier) + if (attr->value[0] != '/') + snprintf(full_path, sizeof(full_path), + "%s/profiles/%s", CUPSDATA, attr->value); +- else ++ else { + strncpy(full_path, attr->value, sizeof(full_path)); ++ if (strlen(attr->value) > 1023) ++ full_path[1023] = '\0'; ++ } + + /* check the file exists */ + if (access(full_path, 0)) { +diff --git a/cupsfilters/image-sgilib.c b/cupsfilters/image-sgilib.c +index 0b70c13..bf2dd80 100644 +--- a/cupsfilters/image-sgilib.c ++++ b/cupsfilters/image-sgilib.c +@@ -282,7 +282,7 @@ sgiOpenFile(FILE *file, /* I - File to open */ + sgip->mode = SGI_WRITE; + + putshort(SGI_MAGIC, sgip->file); +- putc((sgip->comp = comp) != 0, sgip->file); ++ putc(((sgip->comp = comp) != 0) ? '1': '0', sgip->file); + putc(sgip->bpp = bpp, sgip->file); + putshort(3, sgip->file); /* Dimensions */ + putshort(sgip->xsize = xsize, sgip->file); +diff --git a/cupsfilters/image-sun.c b/cupsfilters/image-sun.c +index 609b194..989d039 100644 +--- a/cupsfilters/image-sun.c ++++ b/cupsfilters/image-sun.c +@@ -114,6 +114,7 @@ _cupsImageReadSunRaster( + ras_depth == 0 || ras_depth > 32) + { + fputs("DEBUG: Raster image cannot be loaded!\n", stderr); ++ fclose(fp); + return (1); + } + +diff --git a/cupsfilters/ppdgenerator.c b/cupsfilters/ppdgenerator.c +index 052e3c5..3bc4d8a 100644 +--- a/cupsfilters/ppdgenerator.c ++++ b/cupsfilters/ppdgenerator.c +@@ -937,6 +937,10 @@ load_opt_strings_catalog(const char *location, cups_array_t *options) + } + } + cupsFileClose(fp); ++ if (choice_name != NULL) ++ free(choice_name); ++ if (opt_name != NULL) ++ free(opt_name); + if (filename == tmpfile) + unlink(filename); + } +diff --git a/cupsfilters/raster.c b/cupsfilters/raster.c +index 8203690..67d6b9b 100644 +--- a/cupsfilters/raster.c ++++ b/cupsfilters/raster.c +@@ -151,11 +151,14 @@ cupsRasterParseIPPOptions(cups_page_header2_t *h, /* I - Raster header */ + strcasestr(s, "right") || + strcasestr(s, "side") || + strcasestr(s, "main")) +- media_source = strdup(s); ++ { ++ if (media_source == NULL) ++ media_source = strdup(s); ++ } + else + media_type = strdup(s); + } +- if (size_found) ++ if (page_size == NULL && size_found) + page_size = strdup(size_found->pwg); + } + } +@@ -1079,6 +1082,13 @@ cupsRasterParseIPPOptions(cups_page_header2_t *h, /* I - Raster header */ + h->cupsRenderingIntent[0] = '\0'; + #endif /* HAVE_CUPS_1_7 */ + ++ if (media_source != NULL) ++ free(media_source); ++ if (media_type != NULL) ++ free(media_type); ++ if (page_size != NULL) ++ free(page_size); ++ + return (0); + } + +diff --git a/filter/bannertopdf.c b/filter/bannertopdf.c +index b78ea37..2b9bd76 100644 +--- a/filter/bannertopdf.c ++++ b/filter/bannertopdf.c +@@ -513,6 +513,15 @@ static int generate_banner_pdf(banner_t *banner, + pdf_duplicate_page(doc, 1, copies); + + pdf_write(doc, stdout); ++ ++ opt_t * opt_current = known_opts; ++ opt_t * opt_next = NULL; ++ while (opt_current != NULL) ++ { ++ opt_next = opt_current->next; ++ free(opt_current); ++ opt_current = opt_next; ++ } + free(buf); + pdf_free(doc); + return 0; +diff --git a/filter/foomatic-rip/foomaticrip.c b/filter/foomatic-rip/foomaticrip.c +index 2a642ed..13d2035 100644 +--- a/filter/foomatic-rip/foomaticrip.c ++++ b/filter/foomatic-rip/foomaticrip.c +@@ -666,6 +666,11 @@ int print_file(const char *filename, int convert) + ret = print_file("", 0); + + wait_for_process(renderer_pid); ++ if (in != NULL) ++ fclose(in); ++ if (out != NULL) ++ fclose(out); ++ + return ret; + } + +@@ -683,6 +688,8 @@ int print_file(const char *filename, int convert) + + case UNKNOWN_FILE: + _log("Cannot process \"%s\": Unknown filetype.\n", filename); ++ if (file != NULL) ++ fclose(file); + return 0; + } + +@@ -811,10 +818,14 @@ int main(int argc, char** argv) + + if (getenv("PPD")) { + strncpy(job->ppdfile, getenv("PPD"), 2048); ++ if (strlen(getenv("PPD")) > 2047) ++ job->ppdfile[2047] = '\0'; + spooler = SPOOLER_CUPS; +- if (getenv("CUPS_SERVERBIN")) +- strncpy(cupsfilterpath, getenv("CUPS_SERVERBIN"), +- sizeof(cupsfilterpath)); ++ if (getenv("CUPS_SERVERBIN")) { ++ strncpy(cupsfilterpath, getenv("CUPS_SERVERBIN"), sizeof(cupsfilterpath)); ++ if (strlen(getenv("CUPS_SERVERBIN")) > PATH_MAX-1) ++ cupsfilterpath[PATH_MAX-1] = '\0'; ++ } + } + + /* Check status of printer color management from the color manager */ +@@ -834,10 +845,14 @@ int main(int argc, char** argv) + allow duplicates, and use the last specified one */ + while ((str = arglist_get_value(arglist, "-p"))) { + strncpy(job->ppdfile, str, 2048); ++ if (strlen(str) > 2047) ++ job->ppdfile[2047] = '\0'; + arglist_remove(arglist, "-p"); + } + while ((str = arglist_get_value(arglist, "--ppd"))) { + strncpy(job->ppdfile, str, 2048); ++ if (strlen(str) > 2047) ++ job->ppdfile[2047] = '\0'; + arglist_remove(arglist, "--ppd"); + } + +@@ -1020,6 +1035,7 @@ int main(int argc, char** argv) + cmd[0] = '\0'; + + snprintf(gstoraster, sizeof(gstoraster), "gs -dQUIET -dDEBUG -dPARANOIDSAFER -dNOPAUSE -dBATCH -dNOINTERPOLATE -dNOMEDIAATTRS -sDEVICE=cups -dShowAcroForm %s -sOutputFile=- -", cmd); ++ free(icc_profile); + } + + /* build Ghostscript/CUPS driver command line */ +diff --git a/filter/foomatic-rip/options.c b/filter/foomatic-rip/options.c +index 325a0a6..798ddf9 100644 +--- a/filter/foomatic-rip/options.c ++++ b/filter/foomatic-rip/options.c +@@ -1031,12 +1031,10 @@ int option_set_value(option_t *opt, int optionset, const char *value) + /* TODO only set the changed option, not all of them */ + choice = option_find_choice(fromopt, + option_get_value(fromopt, optionset)); +- + composite_set_values(fromopt, optionset, choice->command); +- } +- else { ++ free(newvalue); ++ } else + val->value = newvalue; +- } + + if (option_is_composite(opt)) { + /* set dependent values */ +@@ -1914,6 +1912,8 @@ int ppd_supports_pdf() + if (startswith(cmd, "gs")) + { + strncpy(cmd_pdf, cmd, 4096); ++ if (strlen(cmd) > 4095) ++ cmd_pdf[4095] = '\0'; + return 1; + } + +diff --git a/filter/foomatic-rip/spooler.c b/filter/foomatic-rip/spooler.c +index 236551f..4f27563 100644 +--- a/filter/foomatic-rip/spooler.c ++++ b/filter/foomatic-rip/spooler.c +@@ -94,6 +94,8 @@ void init_cups(list_t *arglist, dstr_t *filelist, jobparams_t *job) + CUPS puts the print queue name into the PRINTER environment variable + when calling filters. */ + strncpy(job->printer, getenv("PRINTER"), 256); ++ if (strlen(getenv("PRINTER")) > 255) ++ job->printer[255] = '\0'; + + free(cups_options); + } +diff --git a/filter/pdftops.c b/filter/pdftops.c +index 55d2ec1..a648444 100644 +--- a/filter/pdftops.c ++++ b/filter/pdftops.c +@@ -427,6 +427,8 @@ main(int argc, /* I - Number of command-line args */ + if ((val = cupsGetOption("make-and-model", num_options, options)) != NULL) + { + strncpy(make_model, val, sizeof(make_model)); ++ if (strlen(val) > 127) ++ make_model[127] = '\0'; + for (ptr = make_model; *ptr; ptr ++) + if (*ptr == '-') *ptr = ' '; + } +diff --git a/filter/pdftoraster.cxx b/filter/pdftoraster.cxx +index 4cd656a..0c63ab8 100644 +--- a/filter/pdftoraster.cxx ++++ b/filter/pdftoraster.cxx +@@ -558,8 +558,10 @@ static void parseOpts(int argc, char **argv) + if (!cm_disabled) + cmGetPrinterIccProfile(getenv("PRINTER"), &profile, ppd); + +- if (profile != NULL) +- colorProfile = cmsOpenProfileFromFile(profile,"r"); ++ if (profile != NULL) { ++ colorProfile = cmsOpenProfileFromFile(profile,"r"); ++ free(profile); ++ } + + #ifdef HAVE_CUPS_1_7 + if ((attr = ppdFindAttr(ppd,"PWGRaster",0)) != 0 && +diff --git a/filter/rastertoescpx.c b/filter/rastertoescpx.c +index 5a3e5df..a0ec416 100644 +--- a/filter/rastertoescpx.c ++++ b/filter/rastertoescpx.c +@@ -1141,7 +1141,10 @@ EndPage(ppd_file_t *ppd, /* I - PPD file */ + } + } + else ++ { + free(DotBuffers[0]); ++ DotBuffers[0] = NULL; ++ } + + /* + * Output a page eject sequence... +@@ -1440,7 +1443,7 @@ CompressData(ppd_file_t *ppd, /* I - PPD file information */ + + printf("\033i"); + putchar(ctable[PrinterPlanes - 1][plane]); +- putchar(type != 0); ++ putchar((type != 0) ? '1': '0'); + putchar(BitPlanes); + putchar(bytes & 255); + putchar(bytes >> 8); +@@ -1470,7 +1473,7 @@ CompressData(ppd_file_t *ppd, /* I - PPD file information */ + bytes *= 8; + + printf("\033."); +- putchar(type != 0); ++ putchar((type != 0) ? '1': '0'); + putchar(ystep); + putchar(xstep); + putchar(rows); +@@ -1907,6 +1910,10 @@ main(int argc, /* I - Number of command-line arguments */ + if (fd != 0) + close(fd); + ++ for (int i = 0; i < 7; i++) ++ if (DotBuffers[i] != NULL) ++ free(DotBuffers[i]); ++ + return (page == 0); + } + +diff --git a/filter/rastertops.c b/filter/rastertops.c +index d5d955b..531eb70 100644 +--- a/filter/rastertops.c ++++ b/filter/rastertops.c +@@ -282,6 +282,8 @@ write_flate(cups_raster_t *ras, /* I - Image data */ + if (fwrite(out, 1, have, stdout) != have) + { + (void)deflateEnd(&strm); ++ if (convertedpix != NULL) ++ free(convertedpix); + return Z_ERRNO; + } + } while (strm.avail_out == 0); +diff --git a/filter/sys5ippprinter.c b/filter/sys5ippprinter.c +index ad75551..9a92c8e 100644 +--- a/filter/sys5ippprinter.c ++++ b/filter/sys5ippprinter.c +@@ -570,6 +570,8 @@ exec_filter(const char *filter, /* I - Filter to execute */ + dup2(fd, 2); + close(fd); + } ++ else ++ close(fd); + fcntl(2, F_SETFL, O_NDELAY); + } + +@@ -578,6 +580,8 @@ exec_filter(const char *filter, /* I - Filter to execute */ + dup2(fd, 3); + close(fd); + } ++ else ++ close(fd); + fcntl(3, F_SETFL, O_NDELAY); + + if ((fd = open("/dev/null", O_RDWR)) > 4) +@@ -585,6 +589,8 @@ exec_filter(const char *filter, /* I - Filter to execute */ + dup2(fd, 4); + close(fd); + } ++ else ++ close(fd); + fcntl(4, F_SETFL, O_NDELAY); + + /* +@@ -654,8 +660,11 @@ exec_filters(cups_array_t *filters, /* I - Array of filters to run */ + { + next = (char *)cupsArrayNext(filters); + +- if (filter[0] == '/') ++ if (filter[0] == '/') { + strncpy(program, filter, sizeof(program)); ++ if (strlen(filter) > 1023) ++ program[1023] = '\0'; ++ } + else + { + if ((cups_serverbin = getenv("CUPS_SERVERBIN")) == NULL) +diff --git a/utils/cups-browsed.c b/utils/cups-browsed.c +index a2a4a08..19a2ac8 100644 +--- a/utils/cups-browsed.c ++++ b/utils/cups-browsed.c +@@ -2245,7 +2245,10 @@ is_disabled(const char *printer, const char *reason) { + pstate = (ipp_pstate_t)ippGetInteger(attr, 0); + else if (!strcmp(ippGetName(attr), "printer-state-message") && + ippGetValueTag(attr) == IPP_TAG_TEXT) { +- free(pstatemsg); ++ if (pstatemsg != NULL) { ++ free(pstatemsg); ++ pstatemsg = NULL; ++ } + p = ippGetString(attr, 0, NULL); + if (p != NULL) pstatemsg = strdup(p); + } +@@ -2262,16 +2265,22 @@ is_disabled(const char *printer, const char *reason) { + case IPP_PRINTER_IDLE: + case IPP_PRINTER_PROCESSING: + ippDelete(response); +- free(pstatemsg); ++ if (pstatemsg != NULL) { ++ free(pstatemsg); ++ pstatemsg = NULL; ++ } + return NULL; + case IPP_PRINTER_STOPPED: + ippDelete(response); + if (reason == NULL) + return pstatemsg; +- else if (strcasestr(pstatemsg, reason) != NULL) ++ else if (pstatemsg != NULL && (strcasestr(pstatemsg, reason) != NULL)) + return pstatemsg; + else { +- free(pstatemsg); ++ if (pstatemsg != NULL) { ++ free(pstatemsg); ++ pstatemsg = NULL; ++ } + return NULL; + } + } +@@ -2280,12 +2289,18 @@ is_disabled(const char *printer, const char *reason) { + debug_printf("No information regarding enabled/disabled found about the requested printer '%s'\n", + printer); + ippDelete(response); +- free(pstatemsg); ++ if (pstatemsg != NULL) { ++ free(pstatemsg); ++ pstatemsg = NULL; ++ } + return NULL; + } + debug_printf("ERROR: Request for printer info failed: %s\n", + cupsLastErrorString()); +- free(pstatemsg); ++ if (pstatemsg != NULL) { ++ free(pstatemsg); ++ pstatemsg = NULL; ++ } + return NULL; + } + +@@ -3040,6 +3055,8 @@ on_printer_state_changed (CupsNotifier *object, + dest_host = p->ip ? p->ip : p->host; + dest_port = p->port; + strncpy(dest_name, remote_cups_queue, sizeof(dest_name)); ++ if (strlen(remote_cups_queue) > 1023) ++ dest_name[1023] = '\0'; + dest_index = i; + debug_printf("Printer %s on host %s, port %d is idle, take this as destination and stop searching.\n", + remote_cups_queue, p->host, p->port); +@@ -3056,8 +3073,9 @@ on_printer_state_changed (CupsNotifier *object, + min_jobs = num_jobs; + dest_host = p->ip ? p->ip : p->host; + dest_port = p->port; +- strncpy(dest_name, remote_cups_queue, +- sizeof(dest_name)); ++ strncpy(dest_name, remote_cups_queue, sizeof(dest_name)); ++ if (strlen(remote_cups_queue) > 1023) ++ dest_name[1023] = '\0'; + dest_index = i; + } + debug_printf("Printer %s on host %s, port %d is printing and it has %d jobs.\n", +@@ -3566,8 +3584,9 @@ create_remote_printer_entry (const char *queue_name, + IPP_TAG_KEYWORD)) != NULL) { + debug_printf(" Attr: %s\n", ippGetName(attr)); + for (i = 0; i < ippGetCount(attr); i ++) { +- strncpy(valuebuffer, ippGetString(attr, i, NULL), +- sizeof(valuebuffer)); ++ strncpy(valuebuffer, ippGetString(attr, i, NULL), sizeof(valuebuffer)); ++ if (strlen(ippGetString(attr, i, NULL)) > 65535) ++ valuebuffer[65535] = '\0'; + debug_printf(" Keyword: %s\n", valuebuffer); + if (valuebuffer[0] > '1') + break; +@@ -3598,8 +3617,9 @@ create_remote_printer_entry (const char *queue_name, + debug_printf(" Value: %s\n", valuebuffer); + if (valuebuffer[0] == '\0') { + for (i = 0; i < ippGetCount(attr); i ++) { +- strncpy(valuebuffer, ippGetString(attr, i, NULL), +- sizeof(valuebuffer)); ++ strncpy(valuebuffer, ippGetString(attr, i, NULL), sizeof(valuebuffer)); ++ if (strlen(ippGetString(attr, i, NULL)) > 65535) ++ valuebuffer[65535] = '\0'; + debug_printf(" Keyword: %s\n", valuebuffer); + if (valuebuffer[0] != '\0') + break; +@@ -3629,8 +3649,9 @@ create_remote_printer_entry (const char *queue_name, + debug_printf(" Value: %s\n", valuebuffer); + if (valuebuffer[0] == '\0') { + for (i = 0; i < ippGetCount(attr); i ++) { +- strncpy(valuebuffer, ippGetString(attr, i, NULL), +- sizeof(valuebuffer)); ++ strncpy(valuebuffer, ippGetString(attr, i, NULL), sizeof(valuebuffer)); ++ if (strlen(ippGetString(attr, i, NULL)) > 65535) ++ valuebuffer[65535] = '\0'; + debug_printf(" Keyword: %s\n", valuebuffer); + if (valuebuffer[0] != '\0') + break; +@@ -3663,8 +3684,9 @@ create_remote_printer_entry (const char *queue_name, + debug_printf(" Value: %s\n", p->queue_name, valuebuffer); + if (valuebuffer[0] == '\0') { + for (i = 0; i < ippGetCount(attr); i ++) { +- strncpy(valuebuffer, ippGetString(attr, i, NULL), +- sizeof(valuebuffer)); ++ strncpy(valuebuffer, ippGetString(attr, i, NULL), sizeof(valuebuffer)); ++ if (strlen(ippGetString(attr, i, NULL)) > 65535) ++ valuebuffer[65535] = '\0'; + debug_printf(" Keyword: %s\n", valuebuffer); + if (valuebuffer[0] != '\0') + break; +@@ -4498,6 +4520,8 @@ gboolean update_cups_queues(gpointer unused) { + } else { + /* Device URI: ipp(s)://:631/printers/ */ + strncpy(device_uri, p->uri, sizeof(device_uri)); ++ if (strlen(p->uri) > HTTP_MAX_URI-1) ++ device_uri[HTTP_MAX_URI-1] = '\0'; + 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", + p->queue_name, device_uri); + } +@@ -4606,6 +4630,8 @@ gboolean update_cups_queues(gpointer unused) { + } else if (!strncmp(line, "*Default", 8)) { + cont_line_read = 0; + strncpy(keyword, line + 8, sizeof(keyword)); ++ if ((strlen(line) + 8) > 1023) ++ keyword[1023] = '\0'; + for (keyptr = keyword; *keyptr; keyptr ++) + if (*keyptr == ':' || isspace(*keyptr & 255)) + break; +@@ -7144,7 +7170,7 @@ read_configuration (const char *filename) + in the configuration file is used. */ + while ((i < cupsArrayCount(command_line_config) && + (value = cupsArrayIndex(command_line_config, i++)) && +- strncpy(line, value, sizeof(line))) || ++ strncpy(line, value, sizeof(line)) && ((strlen(value) > HTTP_MAX_BUFFER-1)? line[HTTP_MAX_BUFFER-1] = '\0': 1)) || + cupsFileGetConf(fp, line, sizeof(line), &value, &linenum)) { + if (linenum < 0) { + /* We are still reading options from the command line ("-o ..."), +@@ -7371,6 +7397,7 @@ read_configuration (const char *filename) + if (filter->cregexp) + regfree(filter->cregexp); + free(filter); ++ filter = NULL; + } + } else if ((!strcasecmp(line, "BrowseInterval") || !strcasecmp(line, "BrowseTimeout")) && value) { + int t = atoi(value); +@@ -7386,8 +7413,11 @@ read_configuration (const char *filename) + debug_printf("Invalid %s value: %d\n", + line, t); + } else if (!strcasecmp(line, "DomainSocket") && value) { +- if (value[0] != '\0') ++ if (value[0] != '\0') { ++ if (DomainSocket != NULL) ++ free(DomainSocket); + DomainSocket = strdup(value); ++ } + } else if ((!strcasecmp(line, "HttpLocalTimeout") || !strcasecmp(line, "HttpRemoteTimeout")) && value) { + int t = atoi(value); + if (t >= 0) { +@@ -7555,6 +7585,10 @@ read_configuration (const char *filename) + } + } + cupsArrayAdd (clusters, cluster); ++ if (start != NULL) { ++ free(start); ++ start = NULL; ++ } + continue; + cluster_fail: + if (cluster) { +@@ -7568,6 +7602,11 @@ read_configuration (const char *filename) + cupsArrayDelete (cluster->members); + } + free(cluster); ++ cluster = NULL; ++ } ++ if (start != NULL) { ++ free(start); ++ start = NULL; + } + } else if (!strcasecmp(line, "LoadBalancing") && value) { + if (!strncasecmp(value, "QueueOnClient", 13)) +@@ -7575,7 +7614,7 @@ read_configuration (const char *filename) + else if (!strncasecmp(value, "QueueOnServers", 14)) + LoadBalancingType = QUEUE_ON_SERVERS; + } else if (!strcasecmp(line, "DefaultOptions") && value) { +- if (strlen(value) > 0) ++ if (DefaultOptions == NULL && strlen(value) > 0) + DefaultOptions = strdup(value); + } else if (!strcasecmp(line, "AutoShutdown") && value) { + char *p, *saveptr; +@@ -7949,10 +7988,12 @@ int main(int argc, char*argv[]) { + daemon, not with remote ones. */ + if (getenv("CUPS_SERVER") != NULL) { + strncpy(local_server_str, getenv("CUPS_SERVER"), sizeof(local_server_str)); ++ if (strlen(getenv("CUPS_SERVER")) > 1023) ++ local_server_str[1023] = '\0'; + } else { + #ifdef CUPS_DEFAULT_DOMAINSOCKET + if (DomainSocket == NULL) +- DomainSocket = CUPS_DEFAULT_DOMAINSOCKET; ++ DomainSocket = strdup(CUPS_DEFAULT_DOMAINSOCKET); + #endif + if (DomainSocket != NULL) { + struct stat sockinfo; /* Domain socket information */ +@@ -8293,6 +8334,11 @@ fail: + if (debug_logfile == 1) + stop_debug_logging(); + ++ if (DefaultOptions != NULL) ++ free(DefaultOptions); ++ if (DomainSocket != NULL) ++ free(DomainSocket); ++ + return ret; + + help: +diff --git a/utils/driverless.c b/utils/driverless.c +index 7fc6dae..fe61e58 100644 +--- a/utils/driverless.c ++++ b/utils/driverless.c +@@ -227,12 +227,16 @@ list_printers (int mode) + + if (txt_usb_mfg[0] != '\0') { + strncpy(make, txt_usb_mfg, sizeof(make)); ++ if (strlen(txt_usb_mfg) > 511) ++ make[511] = '\0'; + ptr = device_id + strlen(device_id); + snprintf(ptr, sizeof(device_id) - (size_t)(ptr - device_id), + "MFG:%s;", txt_usb_mfg); + } + if (txt_usb_mdl[0] != '\0') { + strncpy(model, txt_usb_mdl, sizeof(model)); ++ if (strlen(txt_usb_mdl) > 255) ++ model[255] = '\0'; + ptr = device_id + strlen(device_id); + snprintf(ptr, sizeof(device_id) - (size_t)(ptr - device_id), + "MDL:%s;", txt_usb_mdl); +@@ -243,15 +247,22 @@ list_printers (int mode) + *ptr == ')') + *ptr = '\0'; + strncpy(model, txt_product + 1, sizeof(model)); ++ if ((strlen(txt_product) + 1) > 255) ++ model[255] = '\0'; + } else + strncpy(model, txt_product, sizeof(model)); + } else if (txt_ty[0] != '\0') { + strncpy(model, txt_ty, sizeof(model)); ++ if (strlen(txt_ty) > 255) ++ model[255] = '\0'; + if ((ptr = strchr(model, ',')) != NULL) + *ptr = '\0'; + } +- if (txt_pdl[0] != '\0') ++ if (txt_pdl[0] != '\0') { + strncpy(pdl, txt_pdl, sizeof(pdl)); ++ if (strlen(txt_pdl) > 255) ++ pdl[255] = '\0'; ++ } + + if (!device_id[0] && strcasecmp(model, "Unknown")) { + if (make[0]) diff --git a/cups-filters.spec b/cups-filters.spec index f1ed072..f39e1b6 100644 --- a/cups-filters.spec +++ b/cups-filters.spec @@ -4,7 +4,7 @@ Summary: OpenPrinting CUPS filters and backends Name: cups-filters Version: 1.20.3 -Release: 7%{?dist} +Release: 8%{?dist} # For a breakdown of the licensing, see COPYING file # GPLv2: filters: commandto*, imagetoraster, pdftops, rasterto*, @@ -22,6 +22,7 @@ Source0: http://www.openprinting.org/download/cups-filters/cups-filters-%{versio Patch01: cups-filters-createall.patch Patch02: poppler-0.64.patch +Patch03: cups-filters-covscan.patch Requires: cups-filters-libs%{?_isa} = %{version}-%{release} @@ -121,6 +122,8 @@ This is the development package for OpenPrinting CUPS filters and backends. # set LocalQueueNamingRemoteCUPS and CreateIPPPrinterQueues by default %patch01 -p1 -b .createall %patch02 -p1 -b .poppler-0.64 +# covscan fixes from upstream +%patch03 -p1 -b .covscan %build # work-around Rpath @@ -293,6 +296,9 @@ fi %{_libdir}/libfontembed.so %changelog +* Fri Sep 21 2018 Zdenek Dohnal - 1.20.3-8 +- covscan fixes from upstream + * Tue Aug 14 2018 Marek Kasik - 1.20.3-7 - Rebuild for poppler-0.67.0 From 1232d7cb5d15c5b90a95d16b85133f699fc872a6 Mon Sep 17 00:00:00 2001 From: Zdenek Dohnal Date: Fri, 21 Sep 2018 14:11:58 +0200 Subject: [PATCH 2/6] covscan fixes from upstream 1628255 - Sticky EOF behavior in glibc breaks descriptor concatenation using dup2 (breaks printing) --- cups-filters-cleareof.patch | 11 +++++++++++ cups-filters.spec | 6 ++++++ 2 files changed, 17 insertions(+) create mode 100644 cups-filters-cleareof.patch diff --git a/cups-filters-cleareof.patch b/cups-filters-cleareof.patch new file mode 100644 index 0000000..8b9731f --- /dev/null +++ b/cups-filters-cleareof.patch @@ -0,0 +1,11 @@ +diff -up cups-filters-1.20.3/filter/foomatic-rip/foomaticrip.c.cleareof cups-filters-1.20.3/filter/foomatic-rip/foomaticrip.c +--- cups-filters-1.20.3/filter/foomatic-rip/foomaticrip.c.cleareof 2018-09-21 13:38:05.882666106 +0200 ++++ cups-filters-1.20.3/filter/foomatic-rip/foomaticrip.c 2018-09-21 13:38:55.330277816 +0200 +@@ -663,6 +663,7 @@ int print_file(const char *filename, int + rip_die(EXIT_PRNERR_NORETRY_BAD_SETTINGS, + "Couldn't dup stdout of pdf-to-ps\n"); + ++ clearerr(stdin); + ret = print_file("", 0); + + wait_for_process(renderer_pid); diff --git a/cups-filters.spec b/cups-filters.spec index f39e1b6..dca308f 100644 --- a/cups-filters.spec +++ b/cups-filters.spec @@ -23,6 +23,7 @@ Source0: http://www.openprinting.org/download/cups-filters/cups-filters-%{versio Patch01: cups-filters-createall.patch Patch02: poppler-0.64.patch Patch03: cups-filters-covscan.patch +Patch04: cups-filters-cleareof.patch Requires: cups-filters-libs%{?_isa} = %{version}-%{release} @@ -124,6 +125,10 @@ This is the development package for OpenPrinting CUPS filters and backends. %patch02 -p1 -b .poppler-0.64 # covscan fixes from upstream %patch03 -p1 -b .covscan +# backported from upstream - glibc changed stream concatenation, so foomatic-rip filter +# needs to react - there is a need to clear eof from descriptor, because there is EOF +# after last io operation +%patch04 -p1 -b .cleareof %build # work-around Rpath @@ -298,6 +303,7 @@ fi %changelog * Fri Sep 21 2018 Zdenek Dohnal - 1.20.3-8 - covscan fixes from upstream +- 1628255 - Sticky EOF behavior in glibc breaks descriptor concatenation using dup2 (breaks printing) * Tue Aug 14 2018 Marek Kasik - 1.20.3-7 - Rebuild for poppler-0.67.0 From f1a38cb3c823e7a42cd41453f4e256353e89f6c4 Mon Sep 17 00:00:00 2001 From: Zdenek Dohnal Date: Mon, 24 Sep 2018 16:49:56 +0200 Subject: [PATCH 3/6] 1632267 - cups-filters needs to obsolete ghostscript-cups and foomatic-filters --- cups-filters.spec | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cups-filters.spec b/cups-filters.spec index dca308f..8469325 100644 --- a/cups-filters.spec +++ b/cups-filters.spec @@ -4,7 +4,7 @@ Summary: OpenPrinting CUPS filters and backends Name: cups-filters Version: 1.20.3 -Release: 8%{?dist} +Release: 9%{?dist} # For a breakdown of the licensing, see COPYING file # GPLv2: filters: commandto*, imagetoraster, pdftops, rasterto*, @@ -93,6 +93,11 @@ Requires(post): systemd Requires(preun): systemd Requires(postun): systemd +# some installations can still have ghostscript-cups and foomatic-filters, +# we need Obsoletes for their successful uninstallation +Obsoletes: ghostscript-cups +Obsoletes: foomatic-filters + %package libs Summary: OpenPrinting CUPS filters and backends - cupsfilters and fontembed libraries # LGPLv2: libcupsfilters @@ -301,6 +306,9 @@ fi %{_libdir}/libfontembed.so %changelog +* Mon Sep 24 2018 Zdenek Dohnal - 1.20.3-9 +- 1632267 - cups-filters needs to obsolete ghostscript-cups and foomatic-filters + * Fri Sep 21 2018 Zdenek Dohnal - 1.20.3-8 - covscan fixes from upstream - 1628255 - Sticky EOF behavior in glibc breaks descriptor concatenation using dup2 (breaks printing) From 7f581c1d218babee4f806efe4304ef326860d48d Mon Sep 17 00:00:00 2001 From: Zdenek Dohnal Date: Mon, 12 Nov 2018 14:45:13 +0100 Subject: [PATCH 4/6] links in man page are wrong --- cups-browsed.8.patch | 14 ++++++++++++++ cups-filters.spec | 7 ++++++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 cups-browsed.8.patch diff --git a/cups-browsed.8.patch b/cups-browsed.8.patch new file mode 100644 index 0000000..583c758 --- /dev/null +++ b/cups-browsed.8.patch @@ -0,0 +1,14 @@ +diff -up cups-filters-1.20.0/utils/cups-browsed.8.manpage cups-filters-1.20.0/utils/cups-browsed.8 +--- cups-filters-1.20.0/utils/cups-browsed.8.manpage 2018-11-12 14:14:48.436062013 +0100 ++++ cups-filters-1.20.0/utils/cups-browsed.8 2018-11-12 14:19:10.188091043 +0100 +@@ -100,8 +100,8 @@ and command line tools. + + \fBcups-browsed.conf\fP(5) + .PP +-/usr/share/doc/\fBcups-browsed\fP/README.gz ++/usr/share/doc/cups-filters/README.gz + .SH AUTHOR +-The authors of \fBcups-browsed\fP are listed in /usr/share/doc/\fBcups-browsed\fP/AUTHORS. ++The authors of \fBcups-browsed\fP are listed in /usr/share/doc/cups-filters/AUTHORS. + .PP + This manual page was written for the Debian Project, but it may be used by others. diff --git a/cups-filters.spec b/cups-filters.spec index 8469325..b676546 100644 --- a/cups-filters.spec +++ b/cups-filters.spec @@ -4,7 +4,7 @@ Summary: OpenPrinting CUPS filters and backends Name: cups-filters Version: 1.20.3 -Release: 9%{?dist} +Release: 10%{?dist} # For a breakdown of the licensing, see COPYING file # GPLv2: filters: commandto*, imagetoraster, pdftops, rasterto*, @@ -24,6 +24,7 @@ Patch01: cups-filters-createall.patch Patch02: poppler-0.64.patch Patch03: cups-filters-covscan.patch Patch04: cups-filters-cleareof.patch +Patch05: cups-browsed.8.patch Requires: cups-filters-libs%{?_isa} = %{version}-%{release} @@ -134,6 +135,7 @@ This is the development package for OpenPrinting CUPS filters and backends. # needs to react - there is a need to clear eof from descriptor, because there is EOF # after last io operation %patch04 -p1 -b .cleareof +%patch05 -p1 -b .manpage %build # work-around Rpath @@ -306,6 +308,9 @@ fi %{_libdir}/libfontembed.so %changelog +* Mon Nov 12 2018 Zdenek Dohnal - 1.20.3-10 +- links in man page are wrong + * Mon Sep 24 2018 Zdenek Dohnal - 1.20.3-9 - 1632267 - cups-filters needs to obsolete ghostscript-cups and foomatic-filters From 15af124bc7faca8a2dd75d562ea35d3c4fe4752b Mon Sep 17 00:00:00 2001 From: Zdenek Dohnal Date: Fri, 14 Dec 2018 14:12:51 +0100 Subject: [PATCH 5/6] 1648697 - cups-browsed keeps re-adding printer after HTTP error (triggers high CPU load in cupsd) --- cups-filters-timeouts.patch | 283 ++++++++++++++++++++++++++++++++++++ cups-filters.spec | 11 +- 2 files changed, 293 insertions(+), 1 deletion(-) create mode 100644 cups-filters-timeouts.patch diff --git a/cups-filters-timeouts.patch b/cups-filters-timeouts.patch new file mode 100644 index 0000000..5920842 --- /dev/null +++ b/cups-filters-timeouts.patch @@ -0,0 +1,283 @@ +diff --git a/utils/cups-browsed.c b/utils/cups-browsed.c +index df3eec2..6b29f63 100644 +--- a/utils/cups-browsed.c ++++ b/utils/cups-browsed.c +@@ -186,6 +186,7 @@ typedef struct remote_printer_s { + int no_autosave; + int netprinter; + int is_legacy; ++ int timeouted; + } remote_printer_t; + + /* Data structure for network interfaces */ +@@ -381,6 +382,7 @@ static char local_server_str[1024]; + static char *DomainSocket = NULL; + static unsigned int HttpLocalTimeout = 5; + static unsigned int HttpRemoteTimeout = 10; ++static unsigned int HttpMaxRetries = 5; + static ip_based_uris_t IPBasedDeviceURIs = IP_BASED_URIS_NO; + static local_queue_naming_t LocalQueueNamingRemoteCUPS=LOCAL_QUEUE_NAMING_DNSSD; + static local_queue_naming_t LocalQueueNamingIPPPrinter=LOCAL_QUEUE_NAMING_DNSSD; +@@ -420,6 +422,9 @@ static char remote_default_printer_file[1024]; + static char save_options_file[1024]; + static char debug_log_file[1024]; + ++/* Static global variable for indicating we have reached the HTTP timeout */ ++static int timeout_reached = 0; ++ + static void recheck_timer (void); + static void browse_poll_create_subscription (browsepoll_t *context, + http_t *conn); +@@ -635,6 +640,7 @@ int + http_timeout_cb(http_t *http, void *user_data) + { + debug_printf("HTTP timeout! (consider increasing HttpLocalTimeout/HttpRemoteTimeout value)\n"); ++ timeout_reached = 1; + return 0; + } + +@@ -3555,6 +3561,10 @@ create_remote_printer_entry (const char *queue_name, + CUPS broadcast (1) or through DNS-SD (0) */ + p->is_legacy = 0; + ++ /* Initialize field for how many timeouts cups-browsed experienced ++ in a row during creation of this printer's queue */ ++ p->timeouted = 0; ++ + /* Remote CUPS printer or local queue remaining from previous cups-browsed + session */ + /* is_cups_queue: -1: Unknown, 0: IPP printer, 1: Remote CUPS queue, +@@ -4257,7 +4267,7 @@ gboolean update_cups_queues(gpointer unused) { + int num_jobs; + cups_job_t *jobs; + ipp_t *request; +- time_t current_time = time(NULL); ++ time_t current_time; + int i, new_cupsfilter_line_inserted, ap_remote_queue_id_line_inserted, + cont_line_read, want_raw; + char *disabled_str, *ptr, *prefix; +@@ -4300,6 +4310,11 @@ gboolean update_cups_queues(gpointer unused) { + for (p = (remote_printer_t *)cupsArrayFirst(remote_printers); + p; p = (remote_printer_t *)cupsArrayNext(remote_printers)) { + ++ /* We need to get the current time as precise as possible for retries ++ and reset the timeout flag */ ++ current_time = time(NULL); ++ timeout_reached = 0; ++ + /* terminating means we have received a signal and should shut down. + in_shutdown means we have exited the main loop. + update_cups_queues() is called after having exited the main loop +@@ -4339,8 +4354,10 @@ gboolean update_cups_queues(gpointer unused) { + if ((q = p->slave_of) == NULL) { + if ((http = http_connect_local ()) == NULL) { + debug_printf("Unable to connect to CUPS!\n"); +- if (in_shutdown == 0) ++ if (in_shutdown == 0) { ++ current_time = time(NULL); + p->timeout = current_time + TIMEOUT_RETRY; ++ } + break; + } + +@@ -4375,6 +4392,7 @@ gboolean update_cups_queues(gpointer unused) { + if (cupsLastError() > IPP_STATUS_OK_EVENTS_COMPLETE) { + debug_printf("Unable to remove \"cups-browsed=true\" from CUPS queue!\n"); + if (in_shutdown == 0) { ++ current_time = time(NULL); + p->timeout = current_time + TIMEOUT_RETRY; + p->no_autosave = 0; + break; +@@ -4402,6 +4420,7 @@ gboolean update_cups_queues(gpointer unused) { + "Printer disappeared or cups-browsed shutdown"); + /* Schedule the removal of the queue for later */ + if (in_shutdown == 0) { ++ current_time = time(NULL); + p->timeout = current_time + TIMEOUT_RETRY; + p->no_autosave = 0; + break; +@@ -4421,6 +4440,7 @@ gboolean update_cups_queues(gpointer unused) { + if (cups_notifier == NULL && is_cups_default_printer(p->queue_name)) { + /* Schedule the removal of the queue for later */ + if (in_shutdown == 0) { ++ current_time = time(NULL); + p->timeout = current_time + TIMEOUT_RETRY; + p->no_autosave = 0; + break; +@@ -4444,6 +4464,7 @@ gboolean update_cups_queues(gpointer unused) { + if (cupsLastError() > IPP_STATUS_OK_EVENTS_COMPLETE) { + debug_printf("Unable to remove CUPS queue!\n"); + if (in_shutdown == 0) { ++ current_time = time(NULL); + p->timeout = current_time + TIMEOUT_RETRY; + p->no_autosave = 0; + break; +@@ -4516,12 +4537,21 @@ gboolean update_cups_queues(gpointer unused) { + if (p->timeout > current_time) + break; + ++ /* cups-browsed tried to add this print queue unsuccessfully for too ++ many times due to timeouts - Skip print queue creation for this one */ ++ if (p->timeouted >= HttpMaxRetries) { ++ fprintf(stderr, "Max number of retries (%d) for creating print queue %s reached, skipping it.\n", ++ HttpMaxRetries, p->queue_name); ++ continue; ++ } ++ + debug_printf("Creating/Updating CUPS queue %s\n", + p->queue_name); + + /* Make sure to have a connection to the local CUPS daemon */ + if ((http = http_connect_local ()) == NULL) { + debug_printf("Unable to connect to CUPS!\n"); ++ current_time = time(NULL); + p->timeout = current_time + TIMEOUT_RETRY; + break; + } +@@ -4609,6 +4639,7 @@ gboolean update_cups_queues(gpointer unused) { + cupsFreeJobs(num_jobs, jobs); + /* Schedule the removal of the queue for later */ + if (in_shutdown == 0) { ++ current_time = time(NULL); + p->timeout = current_time + TIMEOUT_RETRY; + p->no_autosave = 0; + break; +@@ -4624,6 +4655,7 @@ gboolean update_cups_queues(gpointer unused) { + if (cupsLastError() > IPP_STATUS_OK_EVENTS_COMPLETE) { + debug_printf("Unable to remove temporary CUPS queue, retrying later\n"); + if (in_shutdown == 0) { ++ current_time = time(NULL); + p->timeout = current_time + TIMEOUT_RETRY; + p->no_autosave = 0; + break; +@@ -4693,6 +4725,7 @@ gboolean update_cups_queues(gpointer unused) { + == NULL) { + debug_printf("Could not connect to the server %s:%d for %s!\n", + p->host, p->port, p->queue_name); ++ current_time = time(NULL); + p->timeout = current_time + TIMEOUT_RETRY; + p->no_autosave = 0; + break; +@@ -4703,6 +4736,7 @@ gboolean update_cups_queues(gpointer unused) { + CreateRemoteRawPrinterQueues == 0) { + debug_printf("Unable to load PPD file for %s from the server %s:%d!\n", + p->queue_name, p->host, p->port); ++ current_time = time(NULL); + p->timeout = current_time + TIMEOUT_RETRY; + p->no_autosave = 0; + httpClose(remote_http); +@@ -4741,6 +4775,7 @@ gboolean update_cups_queues(gpointer unused) { + ppd_status_t status = ppdLastError(&linenum); + debug_printf("Unable to open PPD \"%s\": %s on line %d.", + loadedppd, ppdErrorString(status), linenum); ++ current_time = time(NULL); + p->timeout = current_time + TIMEOUT_RETRY; + p->no_autosave = 0; + unlink(loadedppd); +@@ -4750,6 +4785,7 @@ gboolean update_cups_queues(gpointer unused) { + cupsMarkOptions(ppd, p->num_options, p->options); + if ((out = cupsTempFile2(buf, sizeof(buf))) == NULL) { + debug_printf("Unable to create temporary file!\n"); ++ current_time = time(NULL); + p->timeout = current_time + TIMEOUT_RETRY; + p->no_autosave = 0; + ppdClose(ppd); +@@ -4758,6 +4794,7 @@ gboolean update_cups_queues(gpointer unused) { + } + if ((in = cupsFileOpen(loadedppd, "r")) == NULL) { + debug_printf("Unable to open the downloaded PPD file!\n"); ++ current_time = time(NULL); + p->timeout = current_time + TIMEOUT_RETRY; + p->no_autosave = 0; + cupsFileClose(out); +@@ -4960,6 +4997,7 @@ gboolean update_cups_queues(gpointer unused) { + if (cupsLastError() > IPP_STATUS_OK_EVENTS_COMPLETE) { + debug_printf("Unable to create/modify CUPS queue (%s)!\n", + cupsLastErrorString()); ++ current_time = time(NULL); + p->timeout = current_time + TIMEOUT_RETRY; + p->no_autosave = 0; + break; +@@ -5060,6 +5098,24 @@ gboolean update_cups_queues(gpointer unused) { + } else + p->timeout = (time_t) -1; + ++ /* Check if an HTTP timeout happened during the print queue creation ++ If it does - increment p->timeouted and set status to TO_BE_CREATED ++ because the creation can fall through the process, have state changed to ++ STATUS_CONFIRMED and experience the timeout */ ++ /* If no timeout has happened, clear p->timeouted */ ++ if (timeout_reached == 1) { ++ fprintf(stderr, "Timeout happened during creation of the queue %s, turn on DebugLogging for more info.\n", p->queue_name); ++ p->timeouted ++; ++ debug_printf("The queue %s already timeouted %d times in a row.\n", ++ p->queue_name, p->timeouted); ++ p->status = STATUS_TO_BE_CREATED; ++ p->timeout = current_time + TIMEOUT_RETRY; ++ } else if (p->timeouted != 0) { ++ debug_printf("Creating the queue %s went smoothly after %d timeouts.\n", ++ p->queue_name, p->timeouted); ++ p->timeouted = 0; ++ } ++ + p->no_autosave = 0; + break; + +@@ -7670,6 +7726,16 @@ read_configuration (const char *filename) + } else + debug_printf("Invalid %s value: %d\n", + line, t); ++ } else if (!strcasecmp(line, "HttpMaxRetries") && value) { ++ int t = atoi(value); ++ if (t > 0) { ++ HttpMaxRetries = t; ++ ++ debug_printf("Set %s to %d retries.\n", ++ line, t); ++ } else ++ debug_printf("Invalid %s value: %d\n", ++ line, t); + } else if (!strcasecmp(line, "IPBasedDeviceURIs") && value) { + if (!strcasecmp(value, "IPv4") || !strcasecmp(value, "IPv4Only")) + IPBasedDeviceURIs = IP_BASED_URIS_IPV4_ONLY; +diff --git a/utils/cups-browsed.conf.5 b/utils/cups-browsed.conf.5 +index 721f524..c629d14 100644 +--- a/utils/cups-browsed.conf.5 ++++ b/utils/cups-browsed.conf.5 +@@ -427,6 +427,18 @@ when the server does not respond. + HttpLocalTimeout 5 + HttpRemoteTimeout 10 + ++.fam T ++.fi ++Set how many retries (N) should cups-browsed do for creating print ++queues for remote printers which receive timeouts during print queue ++creation. The printers which are not successfuly set up even after N ++retries, are skipped until the next restart of the service. Note that ++too many retries can cause high CPU load. ++.PP ++.nf ++.fam C ++ HttpMaxRetries 5 ++ + .fam T + .fi + The interval between browsing/broadcasting cycles, local and/or +diff --git a/utils/cups-browsed.conf.in b/utils/cups-browsed.conf.in +index dccb17b..63a9798 100644 +--- a/utils/cups-browsed.conf.in ++++ b/utils/cups-browsed.conf.in +@@ -310,6 +310,13 @@ BrowseRemoteProtocols @BROWSEREMOTEPROTOCOLS@ + # HttpLocalTimeout 5 + # HttpRemoteTimeout 10 + ++# Set how many retries (N) should cups-browsed do for creating print ++# queues for remote printers which receive timeouts during print queue ++# creation. The printers which are not successfuly set up even after ++# N retries, are skipped until the next restart of the service. Note ++# that too many retries can cause high CPU load. ++ ++# HttpMaxRetries 5 + + # Set OnlyUnsupportedByCUPS to "Yes" will make cups-browsed not create + # local queues for remote printers for which CUPS creates queues by diff --git a/cups-filters.spec b/cups-filters.spec index b676546..e6a7ee6 100644 --- a/cups-filters.spec +++ b/cups-filters.spec @@ -4,7 +4,7 @@ Summary: OpenPrinting CUPS filters and backends Name: cups-filters Version: 1.20.3 -Release: 10%{?dist} +Release: 11%{?dist} # For a breakdown of the licensing, see COPYING file # GPLv2: filters: commandto*, imagetoraster, pdftops, rasterto*, @@ -25,6 +25,9 @@ Patch02: poppler-0.64.patch Patch03: cups-filters-covscan.patch Patch04: cups-filters-cleareof.patch Patch05: cups-browsed.8.patch +# backported from upstream - adds HttpMaxTimeouts directive for stopping creating queues +# which got too many timeouts (bug #1648697) +Patch06: cups-filters-timeouts.patch Requires: cups-filters-libs%{?_isa} = %{version}-%{release} @@ -136,6 +139,9 @@ This is the development package for OpenPrinting CUPS filters and backends. # after last io operation %patch04 -p1 -b .cleareof %patch05 -p1 -b .manpage +# backported from upstream - adds HttpMaxTimeouts directive for stopping creating queues +# which got too many timeouts (bug #1648697) +%patch06 -p1 -b .timeouts %build # work-around Rpath @@ -308,6 +314,9 @@ fi %{_libdir}/libfontembed.so %changelog +* Fri Dec 14 2018 Zdenek Dohnal - 1.20.3-11 +- 1648697 - cups-browsed keeps re-adding printer after HTTP error (triggers high CPU load in cupsd) + * Mon Nov 12 2018 Zdenek Dohnal - 1.20.3-10 - links in man page are wrong From 1a9bcebf84a8f077bc408894a3c01c3e389a0c35 Mon Sep 17 00:00:00 2001 From: Zdenek Dohnal Date: Fri, 1 Feb 2019 14:17:15 +0100 Subject: [PATCH 6/6] cups-brf needs to be run as root --- cups-filters.spec | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cups-filters.spec b/cups-filters.spec index e6a7ee6..1e2a1fa 100644 --- a/cups-filters.spec +++ b/cups-filters.spec @@ -4,7 +4,7 @@ Summary: OpenPrinting CUPS filters and backends Name: cups-filters Version: 1.20.3 -Release: 11%{?dist} +Release: 12%{?dist} # For a breakdown of the licensing, see COPYING file # GPLv2: filters: commandto*, imagetoraster, pdftops, rasterto*, @@ -257,7 +257,9 @@ fi %attr(0700,root,root) %{_cups_serverbin}/backend/serial %attr(0755,root,root) %{_cups_serverbin}/backend/implicitclass %attr(0755,root,root) %{_cups_serverbin}/backend/beh -%attr(0755,root,root) %{_cups_serverbin}/backend/cups-brf +# cups-brf needs to be run as root, otherwise it leaves error messages in +# journal +%attr(0700,root,root) %{_cups_serverbin}/backend/cups-brf %{_bindir}/foomatic-rip %{_bindir}/driverless %{_cups_serverbin}/backend/driverless @@ -314,6 +316,9 @@ fi %{_libdir}/libfontembed.so %changelog +* Fri Feb 01 2019 Zdenek Dohnal - 1.20.3-12 +- cups-brf needs to be run as root + * Fri Dec 14 2018 Zdenek Dohnal - 1.20.3-11 - 1648697 - cups-browsed keeps re-adding printer after HTTP error (triggers high CPU load in cupsd)