From 0f342d7f8e5a0a321661ffa1186fda24ef74ff71 Mon Sep 17 00:00:00 2001 From: Zdenek Dohnal Date: Thu, 15 Aug 2024 15:04:16 +0200 Subject: [PATCH] fix memory leaks caused by lspp Resolves: RHEL-54038 --- cups-lspp.patch | 118 +++++++++++++++++++++++++++++------------------- cups.spec | 1 + 2 files changed, 73 insertions(+), 46 deletions(-) diff --git a/cups-lspp.patch b/cups-lspp.patch index f8c694b..b5c2599 100644 --- a/cups-lspp.patch +++ b/cups-lspp.patch @@ -1,6 +1,6 @@ diff -up cups-2.2.6/config.h.in.lspp cups-2.2.6/config.h.in --- cups-2.2.6/config.h.in.lspp 2017-11-01 15:57:53.000000000 +0100 -+++ cups-2.2.6/config.h.in 2024-08-15 10:30:25.180785272 +0200 ++++ cups-2.2.6/config.h.in 2024-08-15 14:55:07.310818870 +0200 @@ -730,4 +730,12 @@ static __inline int _cups_abs(int i) { r # endif /* __GNUC__ || __STDC_VERSION__ */ #endif /* !HAVE_ABS && !abs */ @@ -15,8 +15,8 @@ diff -up cups-2.2.6/config.h.in.lspp cups-2.2.6/config.h.in + #endif /* !_CUPS_CONFIG_H_ */ diff -up cups-2.2.6/config-scripts/cups-lspp.m4.lspp cups-2.2.6/config-scripts/cups-lspp.m4 ---- cups-2.2.6/config-scripts/cups-lspp.m4.lspp 2024-08-15 10:30:25.179785282 +0200 -+++ cups-2.2.6/config-scripts/cups-lspp.m4 2024-08-15 10:30:25.179785282 +0200 +--- cups-2.2.6/config-scripts/cups-lspp.m4.lspp 2024-08-15 14:55:07.310818870 +0200 ++++ cups-2.2.6/config-scripts/cups-lspp.m4 2024-08-15 14:55:07.310818870 +0200 @@ -0,0 +1,36 @@ +dnl +dnl LSPP code for the Common UNIX Printing System (CUPS). @@ -56,7 +56,7 @@ diff -up cups-2.2.6/config-scripts/cups-lspp.m4.lspp cups-2.2.6/config-scripts/c +fi diff -up cups-2.2.6/configure.ac.lspp cups-2.2.6/configure.ac --- cups-2.2.6/configure.ac.lspp 2017-11-01 15:57:53.000000000 +0100 -+++ cups-2.2.6/configure.ac 2024-08-15 10:30:25.180785272 +0200 ++++ cups-2.2.6/configure.ac 2024-08-15 14:55:07.310818870 +0200 @@ -38,6 +38,8 @@ sinclude(config-scripts/cups-startup.m4) sinclude(config-scripts/cups-defaults.m4) sinclude(config-scripts/cups-scripting.m4) @@ -68,7 +68,7 @@ diff -up cups-2.2.6/configure.ac.lspp cups-2.2.6/configure.ac LANGFILES="" diff -up cups-2.2.6/filter/common.c.lspp cups-2.2.6/filter/common.c --- cups-2.2.6/filter/common.c.lspp 2017-11-01 15:57:53.000000000 +0100 -+++ cups-2.2.6/filter/common.c 2024-08-15 10:30:25.180785272 +0200 ++++ cups-2.2.6/filter/common.c 2024-08-15 14:55:07.310818870 +0200 @@ -17,6 +17,12 @@ * Include necessary headers... */ @@ -239,7 +239,7 @@ diff -up cups-2.2.6/filter/common.c.lspp cups-2.2.6/filter/common.c /* diff -up cups-2.2.6/filter/pstops.c.lspp cups-2.2.6/filter/pstops.c --- cups-2.2.6/filter/pstops.c.lspp 2017-11-01 15:57:53.000000000 +0100 -+++ cups-2.2.6/filter/pstops.c 2024-08-15 10:30:25.181785262 +0200 ++++ cups-2.2.6/filter/pstops.c 2024-08-15 14:55:07.311818856 +0200 @@ -3176,6 +3176,18 @@ write_label_prolog(pstops_doc_t *doc, /* { const char *classification; /* CLASSIFICATION environment variable */ @@ -397,7 +397,7 @@ diff -up cups-2.2.6/filter/pstops.c.lspp cups-2.2.6/filter/pstops.c /* diff -up cups-2.2.6/Makedefs.in.lspp cups-2.2.6/Makedefs.in --- cups-2.2.6/Makedefs.in.lspp 2017-11-01 15:57:53.000000000 +0100 -+++ cups-2.2.6/Makedefs.in 2024-08-15 10:30:25.178785292 +0200 ++++ cups-2.2.6/Makedefs.in 2024-08-15 14:55:07.310818870 +0200 @@ -145,7 +145,7 @@ ARFLAGS = @ARFLAGS@ BACKLIBS = @BACKLIBS@ BUILDDIRS = @BUILDDIRS@ @@ -409,7 +409,7 @@ diff -up cups-2.2.6/Makedefs.in.lspp cups-2.2.6/Makedefs.in DBUS_NOTIFIER = @DBUS_NOTIFIER@ diff -up cups-2.2.6/scheduler/client.c.lspp cups-2.2.6/scheduler/client.c --- cups-2.2.6/scheduler/client.c.lspp 2017-11-01 15:57:53.000000000 +0100 -+++ cups-2.2.6/scheduler/client.c 2024-08-15 10:30:25.182785253 +0200 ++++ cups-2.2.6/scheduler/client.c 2024-08-15 14:55:07.311818856 +0200 @@ -22,12 +22,20 @@ #define _HTTP_NO_PRIVATE #include "cupsd.h" @@ -491,7 +491,19 @@ diff -up cups-2.2.6/scheduler/client.c.lspp cups-2.2.6/scheduler/client.c #ifdef AF_LOCAL if (httpAddrFamily(httpGetAddress(con->http)) == AF_LOCAL) { -@@ -562,6 +623,13 @@ cupsdReadClient(cupsd_client_t *con) /* +@@ -522,6 +583,11 @@ cupsdCloseClient(cupsd_client_t *con) /* + } + #endif /* HAVE_AUTHORIZATION_H */ + ++#ifdef WITH_LSPP ++ if (con->scon) ++ cupsdClearString(&con->scon); ++#endif /* WITH_LSPP */ ++ + /* + * Re-enable new client connections if we are going back under the + * limit... +@@ -562,6 +628,13 @@ cupsdReadClient(cupsd_client_t *con) /* mime_type_t *type; /* MIME type of file */ cupsd_printer_t *p; /* Printer */ static unsigned request_id = 0; /* Request ID for temp files */ @@ -505,7 +517,7 @@ diff -up cups-2.2.6/scheduler/client.c.lspp cups-2.2.6/scheduler/client.c status = HTTP_STATUS_CONTINUE; -@@ -1924,7 +1992,73 @@ cupsdReadClient(cupsd_client_t *con) /* +@@ -1924,7 +1997,73 @@ cupsdReadClient(cupsd_client_t *con) /* fchmod(con->file, 0640); fchown(con->file, RunUser, Group); fcntl(con->file, F_SETFD, fcntl(con->file, F_GETFD) | FD_CLOEXEC); @@ -579,7 +591,7 @@ diff -up cups-2.2.6/scheduler/client.c.lspp cups-2.2.6/scheduler/client.c if (httpGetState(con->http) != HTTP_STATE_POST_SEND) { -@@ -3456,6 +3590,49 @@ is_path_absolute(const char *path) /* I +@@ -3456,6 +3595,49 @@ is_path_absolute(const char *path) /* I return (1); } @@ -631,7 +643,7 @@ diff -up cups-2.2.6/scheduler/client.c.lspp cups-2.2.6/scheduler/client.c * 'pipe_command()' - Pipe the output of a command to the remote client. diff -up cups-2.2.6/scheduler/client.h.lspp cups-2.2.6/scheduler/client.h --- cups-2.2.6/scheduler/client.h.lspp 2017-11-01 15:57:53.000000000 +0100 -+++ cups-2.2.6/scheduler/client.h 2024-08-15 10:30:25.182785253 +0200 ++++ cups-2.2.6/scheduler/client.h 2024-08-15 14:55:07.312818843 +0200 @@ -16,6 +16,13 @@ #endif /* HAVE_AUTHORIZATION_H */ @@ -669,8 +681,8 @@ diff -up cups-2.2.6/scheduler/client.h.lspp cups-2.2.6/scheduler/client.h extern int cupsdEndTLS(cupsd_client_t *con); extern int cupsdStartTLS(cupsd_client_t *con); diff -up cups-2.2.6/scheduler/conf.c.lspp cups-2.2.6/scheduler/conf.c ---- cups-2.2.6/scheduler/conf.c.lspp 2024-08-15 10:30:25.174785332 +0200 -+++ cups-2.2.6/scheduler/conf.c 2024-08-15 10:30:25.183785243 +0200 +--- cups-2.2.6/scheduler/conf.c.lspp 2024-08-15 14:55:07.306818923 +0200 ++++ cups-2.2.6/scheduler/conf.c 2024-08-15 14:55:07.312818843 +0200 @@ -40,6 +40,9 @@ # define INADDR_NONE 0xffffffff #endif /* !INADDR_NONE */ @@ -768,8 +780,8 @@ diff -up cups-2.2.6/scheduler/conf.c.lspp cups-2.2.6/scheduler/conf.c /* * 'read_policy()' - Read a definition. diff -up cups-2.2.6/scheduler/conf.h.lspp cups-2.2.6/scheduler/conf.h ---- cups-2.2.6/scheduler/conf.h.lspp 2024-08-15 10:30:25.100786063 +0200 -+++ cups-2.2.6/scheduler/conf.h 2024-08-15 10:30:25.183785243 +0200 +--- cups-2.2.6/scheduler/conf.h.lspp 2024-08-15 14:55:07.250819672 +0200 ++++ cups-2.2.6/scheduler/conf.h 2024-08-15 14:55:07.312818843 +0200 @@ -250,6 +250,13 @@ VAR char *ServerKeychain VALUE(NULL); /* Keychain holding cert + key */ #endif /* HAVE_SSL */ @@ -795,8 +807,8 @@ diff -up cups-2.2.6/scheduler/conf.h.lspp cups-2.2.6/scheduler/conf.h /* * Prototypes... diff -up cups-2.2.6/scheduler/cupsd.h.lspp cups-2.2.6/scheduler/cupsd.h ---- cups-2.2.6/scheduler/cupsd.h.lspp 2024-08-15 10:30:25.165785421 +0200 -+++ cups-2.2.6/scheduler/cupsd.h 2024-08-15 10:30:25.183785243 +0200 +--- cups-2.2.6/scheduler/cupsd.h.lspp 2024-08-15 14:55:07.298819030 +0200 ++++ cups-2.2.6/scheduler/cupsd.h 2024-08-15 14:55:07.312818843 +0200 @@ -36,6 +36,14 @@ # include #endif /* WIN32 */ @@ -820,8 +832,8 @@ diff -up cups-2.2.6/scheduler/cupsd.h.lspp cups-2.2.6/scheduler/cupsd.h \ No newline at end of file +#endif /* HAVE_AVAHI */ diff -up cups-2.2.6/scheduler/ipp.c.lspp cups-2.2.6/scheduler/ipp.c ---- cups-2.2.6/scheduler/ipp.c.lspp 2024-08-15 10:30:25.124785826 +0200 -+++ cups-2.2.6/scheduler/ipp.c 2024-08-15 10:46:15.546220462 +0200 +--- cups-2.2.6/scheduler/ipp.c.lspp 2024-08-15 14:55:07.268819431 +0200 ++++ cups-2.2.6/scheduler/ipp.c 2024-08-15 14:56:15.961900807 +0200 @@ -37,6 +37,12 @@ extern int mbr_check_membership_by_id(uu # endif /* HAVE_MEMBERSHIPPRIV_H */ #endif /* __APPLE__ */ @@ -1067,7 +1079,7 @@ diff -up cups-2.2.6/scheduler/ipp.c.lspp cups-2.2.6/scheduler/ipp.c } } else if (strcmp(attr->values[0].string.text, Classification) && -@@ -1910,9 +2092,53 @@ add_job(cupsd_client_t *con, /* I - Cl +@@ -1910,9 +2092,55 @@ add_job(cupsd_client_t *con, /* I - Cl "job-sheets=\"%s\", " "job-originating-user-name=\"%s\"", Classification, job->username); @@ -1109,19 +1121,21 @@ diff -up cups-2.2.6/scheduler/ipp.c.lspp cups-2.2.6/scheduler/ipp.c + cupsdClearString(&audit_message); + } } -+ -+ if (userheader) -+ free(userheader); -+ if (userfooter) -+ free(userfooter); +#endif /* WITH_LSPP */ } ++#ifdef WITH_LSPP ++ if (userheader) ++ free(userheader); ++ if (userfooter) ++ free(userfooter); ++#endif /* WITH_LSPP */ ++ + /* * See if we need to add the starting sheet... */ -@@ -3694,6 +3920,128 @@ check_rss_recipient( +@@ -3694,6 +3922,128 @@ check_rss_recipient( } @@ -1250,7 +1264,7 @@ diff -up cups-2.2.6/scheduler/ipp.c.lspp cups-2.2.6/scheduler/ipp.c /* * 'check_quotas()' - Check quotas for a printer and user. */ -@@ -4150,6 +4498,15 @@ copy_banner(cupsd_client_t *con, /* I - +@@ -4150,6 +4500,15 @@ copy_banner(cupsd_client_t *con, /* I - char attrname[255], /* Name of attribute */ *s; /* Pointer into name */ ipp_attribute_t *attr; /* Attribute */ @@ -1266,7 +1280,7 @@ diff -up cups-2.2.6/scheduler/ipp.c.lspp cups-2.2.6/scheduler/ipp.c cupsdLogMessage(CUPSD_LOG_DEBUG2, -@@ -4185,6 +4542,85 @@ copy_banner(cupsd_client_t *con, /* I - +@@ -4185,6 +4544,85 @@ copy_banner(cupsd_client_t *con, /* I - fchmod(cupsFileNumber(out), 0640); fchown(cupsFileNumber(out), RunUser, Group); @@ -1352,7 +1366,7 @@ diff -up cups-2.2.6/scheduler/ipp.c.lspp cups-2.2.6/scheduler/ipp.c /* * Try the localized banner file under the subdirectory... -@@ -4279,6 +4715,24 @@ copy_banner(cupsd_client_t *con, /* I - +@@ -4279,6 +4717,24 @@ copy_banner(cupsd_client_t *con, /* I - else s = attrname; @@ -1377,7 +1391,7 @@ diff -up cups-2.2.6/scheduler/ipp.c.lspp cups-2.2.6/scheduler/ipp.c if (!strcmp(s, "printer-name")) { cupsFilePuts(out, job->dest); -@@ -6467,6 +6921,22 @@ get_job_attrs(cupsd_client_t *con, /* I +@@ -6467,6 +6923,22 @@ get_job_attrs(cupsd_client_t *con, /* I exclude = cupsdGetPrivateAttrs(policy, con, printer, job->username); @@ -1400,7 +1414,7 @@ diff -up cups-2.2.6/scheduler/ipp.c.lspp cups-2.2.6/scheduler/ipp.c /* * Copy attributes... */ -@@ -6864,6 +7334,11 @@ get_jobs(cupsd_client_t *con, /* I - C +@@ -6864,6 +7336,11 @@ get_jobs(cupsd_client_t *con, /* I - C if (username[0] && _cups_strcasecmp(username, job->username)) continue; @@ -1412,7 +1426,7 @@ diff -up cups-2.2.6/scheduler/ipp.c.lspp cups-2.2.6/scheduler/ipp.c if (count > 0) ippAddSeparator(con->response); -@@ -11495,6 +11970,11 @@ validate_user(cupsd_job_t *job, /* I +@@ -11495,6 +11972,11 @@ validate_user(cupsd_job_t *job, /* I strlcpy(username, get_username(con), userlen); @@ -1425,8 +1439,8 @@ diff -up cups-2.2.6/scheduler/ipp.c.lspp cups-2.2.6/scheduler/ipp.c * Check the username against the owner... */ diff -up cups-2.2.6/scheduler/job.c.lspp cups-2.2.6/scheduler/job.c ---- cups-2.2.6/scheduler/job.c.lspp 2024-08-15 10:30:25.142785648 +0200 -+++ cups-2.2.6/scheduler/job.c 2024-08-15 10:30:25.189785183 +0200 +--- cups-2.2.6/scheduler/job.c.lspp 2024-08-15 14:55:07.278819298 +0200 ++++ cups-2.2.6/scheduler/job.c 2024-08-15 14:55:07.316818790 +0200 @@ -26,6 +26,12 @@ # endif /* HAVE_IOKIT_PWR_MGT_IOPMLIBPRIVATE_H */ #endif /* __APPLE__ */ @@ -1523,7 +1537,19 @@ diff -up cups-2.2.6/scheduler/job.c.lspp cups-2.2.6/scheduler/job.c if (Classification && !banner_page) { if ((attr = ippFindAttribute(job->attrs, "job-sheets", -@@ -1908,6 +1983,22 @@ cupsdLoadJob(cupsd_job_t *job) /* I - J +@@ -1464,6 +1539,11 @@ cupsdDeleteJob(cupsd_job_t *job, / + + cupsdClearString(&job->username); + cupsdClearString(&job->dest); ++ ++#ifdef WITH_LSPP ++ cupsdClearString(&job->scon); ++#endif ++ + for (i = 0; + i < (int)(sizeof(job->auth_env) / sizeof(job->auth_env[0])); + i ++) +@@ -1908,6 +1988,22 @@ cupsdLoadJob(cupsd_job_t *job) /* I - J ippSetString(job->attrs, &job->reasons, 0, "none"); } @@ -1546,7 +1572,7 @@ diff -up cups-2.2.6/scheduler/job.c.lspp cups-2.2.6/scheduler/job.c job->impressions = ippFindAttribute(job->attrs, "job-impressions-completed", IPP_TAG_INTEGER); job->sheets = ippFindAttribute(job->attrs, "job-media-sheets-completed", IPP_TAG_INTEGER); job->job_sheets = ippFindAttribute(job->attrs, "job-sheets", IPP_TAG_NAME); -@@ -2321,6 +2412,14 @@ cupsdSaveJob(cupsd_job_t *job) /* I - J +@@ -2321,6 +2417,14 @@ cupsdSaveJob(cupsd_job_t *job) /* I - J { char filename[1024]; /* Job control filename */ cups_file_t *fp; /* Job file */ @@ -1561,7 +1587,7 @@ diff -up cups-2.2.6/scheduler/job.c.lspp cups-2.2.6/scheduler/job.c cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdSaveJob(job=%p(%d)): job->attrs=%p", -@@ -2343,6 +2442,78 @@ cupsdSaveJob(cupsd_job_t *job) /* I - J +@@ -2343,6 +2447,78 @@ cupsdSaveJob(cupsd_job_t *job) /* I - J fchown(cupsFileNumber(fp), RunUser, Group); @@ -1640,7 +1666,7 @@ diff -up cups-2.2.6/scheduler/job.c.lspp cups-2.2.6/scheduler/job.c job->attrs->state = IPP_IDLE; if (ippWriteIO(fp, (ipp_iocb_t)cupsFileWrite, 1, NULL, -@@ -3989,6 +4160,19 @@ get_options(cupsd_job_t *job, /* I - Jo +@@ -3989,6 +4165,19 @@ get_options(cupsd_job_t *job, /* I - Jo banner_page) continue; @@ -1660,7 +1686,7 @@ diff -up cups-2.2.6/scheduler/job.c.lspp cups-2.2.6/scheduler/job.c /* * Otherwise add them to the list... */ -@@ -4750,6 +4934,18 @@ start_job(cupsd_job_t *job, /* I - +@@ -4750,6 +4939,18 @@ start_job(cupsd_job_t *job, /* I - cupsd_printer_t *printer) /* I - Printer to print job */ { const char *filename; /* Support filename */ @@ -1679,7 +1705,7 @@ diff -up cups-2.2.6/scheduler/job.c.lspp cups-2.2.6/scheduler/job.c ipp_attribute_t *cancel_after = ippFindAttribute(job->attrs, "job-cancel-after", IPP_TAG_INTEGER); -@@ -4926,6 +5122,113 @@ start_job(cupsd_job_t *job, /* I - +@@ -4926,6 +5127,113 @@ start_job(cupsd_job_t *job, /* I - fcntl(job->side_pipes[1], F_SETFD, fcntl(job->side_pipes[1], F_GETFD) | FD_CLOEXEC); @@ -1795,7 +1821,7 @@ diff -up cups-2.2.6/scheduler/job.c.lspp cups-2.2.6/scheduler/job.c */ diff -up cups-2.2.6/scheduler/job.h.lspp cups-2.2.6/scheduler/job.h --- cups-2.2.6/scheduler/job.h.lspp 2017-11-01 15:57:53.000000000 +0100 -+++ cups-2.2.6/scheduler/job.h 2024-08-15 10:30:25.189785183 +0200 ++++ cups-2.2.6/scheduler/job.h 2024-08-15 14:55:07.316818790 +0200 @@ -11,6 +11,10 @@ * missing or damaged, see the license at "http://www.cups.org/". */ @@ -1819,8 +1845,8 @@ diff -up cups-2.2.6/scheduler/job.h.lspp cups-2.2.6/scheduler/job.h typedef struct cupsd_joblog_s /**** Job log message ****/ diff -up cups-2.2.6/scheduler/main.c.lspp cups-2.2.6/scheduler/main.c ---- cups-2.2.6/scheduler/main.c.lspp 2024-08-15 10:30:25.166785411 +0200 -+++ cups-2.2.6/scheduler/main.c 2024-08-15 10:30:25.189785183 +0200 +--- cups-2.2.6/scheduler/main.c.lspp 2024-08-15 14:55:07.299819017 +0200 ++++ cups-2.2.6/scheduler/main.c 2024-08-15 14:55:07.316818790 +0200 @@ -56,6 +56,9 @@ # include #endif /* HAVE_SYS_PARAM_H */ @@ -1880,8 +1906,8 @@ diff -up cups-2.2.6/scheduler/main.c.lspp cups-2.2.6/scheduler/main.c } diff -up cups-2.2.6/scheduler/printers.c.lspp cups-2.2.6/scheduler/printers.c ---- cups-2.2.6/scheduler/printers.c.lspp 2024-08-15 10:30:25.103786034 +0200 -+++ cups-2.2.6/scheduler/printers.c 2024-08-15 10:30:25.190785173 +0200 +--- cups-2.2.6/scheduler/printers.c.lspp 2024-08-15 14:55:07.253819632 +0200 ++++ cups-2.2.6/scheduler/printers.c 2024-08-15 14:55:07.317818776 +0200 @@ -35,6 +35,10 @@ # include #endif /* __APPLE__ */ diff --git a/cups.spec b/cups.spec index c7605ce..7157f58 100644 --- a/cups.spec +++ b/cups.spec @@ -937,6 +937,7 @@ rm -f %{cups_serverbin}/backend/smb %changelog * Thu Aug 15 2024 Zdenek Dohnal - 1:2.2.6-61 - RHEL-54038 cups source rpm doesn't actually build lspp support +- fix memory leaks caused by lspp * Tue Jun 18 2024 Pavol Zacik - 1:2.2.6-60 - RHEL-40386 cups: Cupsd Listen arbitrary chmod 0140777