fix crash in scheduler (#1253135)

This commit is contained in:
Jiri Popelka 2015-08-13 11:16:19 +02:00
parent 6a53bfe80e
commit c24d1eaaa9
2 changed files with 27 additions and 19 deletions

View File

@ -1,25 +1,30 @@
From d6474c395e14b3079dd198fadf7427c67412e816 Mon Sep 17 00:00:00 2001
From: Jiri Popelka <jpopelka@redhat.com>
Date: Mon, 10 Aug 2015 17:12:32 +0200
Subject: [PATCH] Fix index out of range in cupsdLogJob()
---
scheduler/log.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scheduler/log.c b/scheduler/log.c
index cef0219..21489d5 100644
--- a/scheduler/log.c
+++ b/scheduler/log.c
@@ -667,7 +667,7 @@ cupsdLogJob(cupsd_job_t *job, /* I - Job */
diff -up cups-2.1rc1/scheduler/log.c.journal cups-2.1rc1/scheduler/log.c
--- cups-2.1rc1/scheduler/log.c.journal 2015-08-13 11:12:07.738534615 +0200
+++ cups-2.1rc1/scheduler/log.c 2015-08-13 11:14:41.411980473 +0200
@@ -646,7 +646,7 @@ cupsdLogJob(cupsd_job_t *job, /* I - Jo
asl_set(m, PWG_Event, "JobStateChanged");
asl_set(m, PWG_JobID, job_id);
- asl_set(m, PWG_JobState, job_states[job->state_value - IPP_JSTATE_PENDING]);
+ asl_set(m, PWG_JobState, job->state_value < IPP_JSTATE_PENDING ? "" : job_states[job->state_value - IPP_JSTATE_PENDING]);
if (job->impressions)
{
@@ -666,7 +666,7 @@ cupsdLogJob(cupsd_job_t *job, /* I - Jo
#elif defined(HAVE_SYSTEMD_SD_JOURNAL_H)
if (!strcmp(ErrorLog, "syslog"))
{
- cupsd_printer_t *printer = job->printer ? job->printer : job->dest ? cupsdFindDest(job->dest) : NULL;
+ cupsd_printer_t *printer = job ? (job->printer ? job->printer : (job->dest ? cupsdFindDest(job->dest) : NULL)) : NULL;
static const char * const job_states[] =
{ /* job-state strings */
"Pending",
@@ -696,7 +696,7 @@ cupsdLogJob(cupsd_job_t *job, /* I - Jo
PWG_Event"=JobStateChanged",
PWG_ServiceURI"=%s", printer ? printer->uri : "",
PWG_JobID"=%d", job->id,
- PWG_JobState"=%s", job_states[job->state_value - IPP_JSTATE_PENDING],
+ PWG_JobState"=%s", job->state_value >= IPP_JSTATE_PENDING ? job_states[job->state_value - IPP_JSTATE_PENDING] : "",
+ PWG_JobState"=%s", job->state_value < IPP_JSTATE_PENDING ? "" : job_states[job->state_value - IPP_JSTATE_PENDING],
PWG_JobImpressionsCompleted"=%d", ippGetInteger(job->impressions, 0),
NULL);
else
--
2.5.0

View File

@ -14,7 +14,7 @@ Summary: CUPS printing system
Name: cups
Epoch: 1
Version: 2.1
Release: 0.2%{prever}%{?dist}
Release: 0.3%{prever}%{?dist}
License: GPLv2
Url: http://www.cups.org/
Source0: http://www.cups.org/software/%{VERSION}/cups-%{VERSION}-source.tar.bz2
@ -621,6 +621,9 @@ rm -f %{cups_serverbin}/backend/smb
%{_mandir}/man5/ipptoolfile.5.gz
%changelog
* Thu Aug 13 2015 Jiri Popelka <jpopelka@redhat.com> - 1:2.1-0.3rc1
- fix crash in scheduler (#1253135)
* Mon Aug 10 2015 Jiri Popelka <jpopelka@redhat.com> - 1:2.1-0.2rc1
- better fix for STR#4687