fix memory leaks from LSPP

Resolves: RHEL-6526
This commit is contained in:
Zdenek Dohnal 2024-08-15 14:23:18 +02:00
parent 600a0d705d
commit 520fa88ae2
2 changed files with 52 additions and 25 deletions

View File

@ -415,7 +415,7 @@ index d251abb..8afff4a 100644
/* /*
diff --git a/scheduler/client.c b/scheduler/client.c diff --git a/scheduler/client.c b/scheduler/client.c
index cef4115..229b308 100644 index cef4115..e186e4c 100644
--- a/scheduler/client.c --- a/scheduler/client.c
+++ b/scheduler/client.c +++ b/scheduler/client.c
@@ -19,12 +19,20 @@ @@ -19,12 +19,20 @@
@ -499,7 +499,19 @@ index cef4115..229b308 100644
#ifdef AF_LOCAL #ifdef AF_LOCAL
if (httpAddrFamily(httpGetAddress(con->http)) == AF_LOCAL) if (httpAddrFamily(httpGetAddress(con->http)) == AF_LOCAL)
{ {
@@ -556,6 +617,13 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */ @@ -517,6 +578,11 @@ cupsdCloseClient(cupsd_client_t *con) /* I - Client to close */
}
#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...
@@ -556,6 +622,13 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */
struct stat filestats; /* File information */ struct stat filestats; /* File information */
mime_type_t *type; /* MIME type of file */ mime_type_t *type; /* MIME type of file */
static unsigned request_id = 0; /* Request ID for temp files */ static unsigned request_id = 0; /* Request ID for temp files */
@ -513,7 +525,7 @@ index cef4115..229b308 100644
status = HTTP_STATUS_CONTINUE; status = HTTP_STATUS_CONTINUE;
@@ -1675,7 +1743,73 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */ @@ -1675,7 +1748,73 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */
fchmod(con->file, 0640); fchmod(con->file, 0640);
fchown(con->file, RunUser, Group); fchown(con->file, RunUser, Group);
fcntl(con->file, F_SETFD, fcntl(con->file, F_GETFD) | FD_CLOEXEC); fcntl(con->file, F_SETFD, fcntl(con->file, F_GETFD) | FD_CLOEXEC);
@ -587,7 +599,7 @@ index cef4115..229b308 100644
if (httpGetState(con->http) != HTTP_STATE_POST_SEND) if (httpGetState(con->http) != HTTP_STATE_POST_SEND)
{ {
@@ -3173,6 +3307,49 @@ is_path_absolute(const char *path) /* I - Input path */ @@ -3173,6 +3312,49 @@ is_path_absolute(const char *path) /* I - Input path */
return (1); return (1);
} }
@ -834,7 +846,7 @@ index bc1350e..64d57d1 100644
#if defined(HAVE_CDSASSL) #if defined(HAVE_CDSASSL)
diff --git a/scheduler/ipp.c b/scheduler/ipp.c diff --git a/scheduler/ipp.c b/scheduler/ipp.c
index 19d6608..835f52d 100644 index 19d6608..728d164 100644
--- a/scheduler/ipp.c --- a/scheduler/ipp.c
+++ b/scheduler/ipp.c +++ b/scheduler/ipp.c
@@ -12,6 +12,9 @@ @@ -12,6 +12,9 @@
@ -1092,7 +1104,7 @@ index 19d6608..835f52d 100644
} }
} }
else if (strcmp(attr->values[0].string.text, Classification) && else if (strcmp(attr->values[0].string.text, Classification) &&
@@ -1872,9 +2057,53 @@ add_job(cupsd_client_t *con, /* I - Client connection */ @@ -1872,9 +2057,55 @@ add_job(cupsd_client_t *con, /* I - Client connection */
"job-sheets=\"%s\", " "job-sheets=\"%s\", "
"job-originating-user-name=\"%s\"", "job-originating-user-name=\"%s\"",
Classification, job->username); Classification, job->username);
@ -1134,19 +1146,21 @@ index 19d6608..835f52d 100644
+ cupsdClearString(&audit_message); + cupsdClearString(&audit_message);
+ } + }
} }
+
+ if (userheader)
+ free(userheader);
+ if (userfooter)
+ free(userfooter);
+#endif /* WITH_LSPP */ +#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... * See if we need to add the starting sheet...
*/ */
@@ -3649,6 +3878,128 @@ check_rss_recipient( @@ -3649,6 +3880,128 @@ check_rss_recipient(
} }
@ -1275,7 +1289,7 @@ index 19d6608..835f52d 100644
/* /*
* 'check_quotas()' - Check quotas for a printer and user. * 'check_quotas()' - Check quotas for a printer and user.
*/ */
@@ -4104,6 +4455,15 @@ copy_banner(cupsd_client_t *con, /* I - Client connection */ @@ -4104,6 +4457,15 @@ copy_banner(cupsd_client_t *con, /* I - Client connection */
char attrname[255], /* Name of attribute */ char attrname[255], /* Name of attribute */
*s; /* Pointer into name */ *s; /* Pointer into name */
ipp_attribute_t *attr; /* Attribute */ ipp_attribute_t *attr; /* Attribute */
@ -1291,7 +1305,7 @@ index 19d6608..835f52d 100644
cupsdLogMessage(CUPSD_LOG_DEBUG2, cupsdLogMessage(CUPSD_LOG_DEBUG2,
@@ -4139,6 +4499,85 @@ copy_banner(cupsd_client_t *con, /* I - Client connection */ @@ -4139,6 +4501,85 @@ copy_banner(cupsd_client_t *con, /* I - Client connection */
fchmod(cupsFileNumber(out), 0640); fchmod(cupsFileNumber(out), 0640);
fchown(cupsFileNumber(out), RunUser, Group); fchown(cupsFileNumber(out), RunUser, Group);
@ -1377,7 +1391,7 @@ index 19d6608..835f52d 100644
/* /*
* Try the localized banner file under the subdirectory... * Try the localized banner file under the subdirectory...
@@ -4233,6 +4672,24 @@ copy_banner(cupsd_client_t *con, /* I - Client connection */ @@ -4233,6 +4674,24 @@ copy_banner(cupsd_client_t *con, /* I - Client connection */
else else
s = attrname; s = attrname;
@ -1402,7 +1416,7 @@ index 19d6608..835f52d 100644
if (!strcmp(s, "printer-name")) if (!strcmp(s, "printer-name"))
{ {
cupsFilePuts(out, job->dest); cupsFilePuts(out, job->dest);
@@ -6443,6 +6900,22 @@ get_job_attrs(cupsd_client_t *con, /* I - Client connection */ @@ -6443,6 +6902,22 @@ get_job_attrs(cupsd_client_t *con, /* I - Client connection */
exclude = cupsdGetPrivateAttrs(policy, con, printer, job->username); exclude = cupsdGetPrivateAttrs(policy, con, printer, job->username);
@ -1425,7 +1439,7 @@ index 19d6608..835f52d 100644
/* /*
* Copy attributes... * Copy attributes...
*/ */
@@ -6840,6 +7313,11 @@ get_jobs(cupsd_client_t *con, /* I - Client connection */ @@ -6840,6 +7315,11 @@ get_jobs(cupsd_client_t *con, /* I - Client connection */
if (username[0] && _cups_strcasecmp(username, job->username)) if (username[0] && _cups_strcasecmp(username, job->username))
continue; continue;
@ -1437,7 +1451,7 @@ index 19d6608..835f52d 100644
if (count > 0) if (count > 0)
ippAddSeparator(con->response); ippAddSeparator(con->response);
@@ -11441,6 +11919,11 @@ validate_user(cupsd_job_t *job, /* I - Job */ @@ -11441,6 +11921,11 @@ validate_user(cupsd_job_t *job, /* I - Job */
strlcpy(username, get_username(con), userlen); strlcpy(username, get_username(con), userlen);
@ -1450,7 +1464,7 @@ index 19d6608..835f52d 100644
* Check the username against the owner... * Check the username against the owner...
*/ */
diff --git a/scheduler/job.c b/scheduler/job.c diff --git a/scheduler/job.c b/scheduler/job.c
index 834e170..6cf86df 100644 index 834e170..dbc64c3 100644
--- a/scheduler/job.c --- a/scheduler/job.c
+++ b/scheduler/job.c +++ b/scheduler/job.c
@@ -8,6 +8,9 @@ @@ -8,6 +8,9 @@
@ -1559,7 +1573,19 @@ index 834e170..6cf86df 100644
if (Classification && !banner_page) if (Classification && !banner_page)
{ {
if ((attr = ippFindAttribute(job->attrs, "job-sheets", if ((attr = ippFindAttribute(job->attrs, "job-sheets",
@@ -1844,6 +1922,22 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */ @@ -1400,6 +1478,11 @@ cupsdDeleteJob(cupsd_job_t *job, /* I - 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 ++)
@@ -1844,6 +1927,22 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */
ippSetString(job->attrs, &job->reasons, 0, "none"); ippSetString(job->attrs, &job->reasons, 0, "none");
} }
@ -1582,7 +1608,7 @@ index 834e170..6cf86df 100644
job->impressions = ippFindAttribute(job->attrs, "job-impressions-completed", IPP_TAG_INTEGER); job->impressions = ippFindAttribute(job->attrs, "job-impressions-completed", IPP_TAG_INTEGER);
job->sheets = ippFindAttribute(job->attrs, "job-media-sheets-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); job->job_sheets = ippFindAttribute(job->attrs, "job-sheets", IPP_TAG_NAME);
@@ -2259,6 +2353,14 @@ cupsdSaveJob(cupsd_job_t *job) /* I - Job */ @@ -2259,6 +2358,14 @@ cupsdSaveJob(cupsd_job_t *job) /* I - Job */
{ {
char filename[1024]; /* Job control filename */ char filename[1024]; /* Job control filename */
cups_file_t *fp; /* Job file */ cups_file_t *fp; /* Job file */
@ -1597,7 +1623,7 @@ index 834e170..6cf86df 100644
cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdSaveJob(job=%p(%d)): job->attrs=%p", cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdSaveJob(job=%p(%d)): job->attrs=%p",
@@ -2281,6 +2383,78 @@ cupsdSaveJob(cupsd_job_t *job) /* I - Job */ @@ -2281,6 +2388,78 @@ cupsdSaveJob(cupsd_job_t *job) /* I - Job */
fchown(cupsFileNumber(fp), RunUser, Group); fchown(cupsFileNumber(fp), RunUser, Group);
@ -1676,7 +1702,7 @@ index 834e170..6cf86df 100644
job->attrs->state = IPP_IDLE; job->attrs->state = IPP_IDLE;
if (ippWriteIO(fp, (ipp_iocb_t)cupsFileWrite, 1, NULL, if (ippWriteIO(fp, (ipp_iocb_t)cupsFileWrite, 1, NULL,
@@ -3981,6 +4155,19 @@ get_options(cupsd_job_t *job, /* I - Job */ @@ -3981,6 +4160,19 @@ get_options(cupsd_job_t *job, /* I - Job */
banner_page) banner_page)
continue; continue;
@ -1696,7 +1722,7 @@ index 834e170..6cf86df 100644
/* /*
* Otherwise add them to the list... * Otherwise add them to the list...
*/ */
@@ -4791,6 +4978,18 @@ start_job(cupsd_job_t *job, /* I - Job ID */ @@ -4791,6 +4983,18 @@ start_job(cupsd_job_t *job, /* I - Job ID */
cupsd_printer_t *printer) /* I - Printer to print job */ cupsd_printer_t *printer) /* I - Printer to print job */
{ {
const char *filename; /* Support filename */ const char *filename; /* Support filename */
@ -1715,7 +1741,7 @@ index 834e170..6cf86df 100644
ipp_attribute_t *cancel_after = ippFindAttribute(job->attrs, ipp_attribute_t *cancel_after = ippFindAttribute(job->attrs,
"job-cancel-after", "job-cancel-after",
IPP_TAG_INTEGER); IPP_TAG_INTEGER);
@@ -4979,6 +5178,113 @@ start_job(cupsd_job_t *job, /* I - Job ID */ @@ -4979,6 +5183,113 @@ start_job(cupsd_job_t *job, /* I - Job ID */
fcntl(job->side_pipes[1], F_SETFD, fcntl(job->side_pipes[1], F_SETFD,
fcntl(job->side_pipes[1], F_GETFD) | FD_CLOEXEC); fcntl(job->side_pipes[1], F_GETFD) | FD_CLOEXEC);

View File

@ -864,6 +864,7 @@ rm -f %{cups_serverbin}/backend/smb
%changelog %changelog
* Thu Aug 15 2024 Zdenek Dohnal <zdohnal@redhat.com> - 1:2.3.3op2-30 * Thu Aug 15 2024 Zdenek Dohnal <zdohnal@redhat.com> - 1:2.3.3op2-30
- RHEL-6526 cups source rpm doesn't actually build lspp support - RHEL-6526 cups source rpm doesn't actually build lspp support
- fix memory leaks from LSPP
* Wed Jun 19 2024 Pavol Zacik <pzacik@redhat.com> - 1:2.3.3op2-29 * Wed Jun 19 2024 Pavol Zacik <pzacik@redhat.com> - 1:2.3.3op2-29
- Revert the cups-libs license identifier to the "legacy" format - Revert the cups-libs license identifier to the "legacy" format