Skip to content

Commit 8d0f51c

Browse files
committed
Filter out control characters from option values.
1 parent 730347c commit 8d0f51c

2 files changed

Lines changed: 37 additions & 6 deletions

File tree

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Changes in CUPS v2.4.17 (YYYY-MM-DD)
99
insensitive.
1010
- CVE-2026-NNNNN: The RSS notifier could write outside the scheduler's RSS
1111
directory.
12+
- CVE-2026-NNNNN: The scheduler did not filter control characters from option
13+
values.
1214
- The scheduler followed symbolic links when cleaning out its temporary
1315
directory (Issue #1448)
1416
- Updated `cupsFileGetConf` and `cupsFilePutConf` to escape more characters.

scheduler/job.c

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4118,9 +4118,21 @@ get_options(cupsd_job_t *job, /* I - Job */
41184118
case IPP_TAG_URI :
41194119
for (valptr = attr->values[i].string.text; *valptr;)
41204120
{
4121-
if (strchr(" \t\n\\\'\"", *valptr))
4122-
*optptr++ = '\\';
4123-
*optptr++ = *valptr++;
4121+
/*
4122+
* Convert tabs and newlines to spaces, filter out control chars,
4123+
* and escape \, ', and ".
4124+
*/
4125+
4126+
if (isspace(*valptr & 255))
4127+
{
4128+
*optptr++ = ' ';
4129+
}
4130+
else if ((*valptr & 255) >= ' ' && *valptr != 0x7f)
4131+
{
4132+
if (strchr("\\\'\"", *valptr))
4133+
*optptr++ = '\\';
4134+
*optptr++ = *valptr++;
4135+
}
41244136
}
41254137

41264138
*optptr = '\0';
@@ -5395,13 +5407,30 @@ update_job(cupsd_job_t *job) /* I - Job to check */
53955407
else if (loglevel == CUPSD_LOG_PPD)
53965408
{
53975409
/*
5398-
* Set attribute(s)...
5410+
* Set PPD keyword(s)/value(s)...
53995411
*/
54005412

5413+
int i, /* Looping var */
5414+
num_keywords; /* Number of keywords */
5415+
cups_option_t *keywords, /* Keywords */
5416+
*keyword; /* Current keyword */
5417+
54015418
cupsdLogJob(job, CUPSD_LOG_DEBUG, "PPD: %s", message);
54025419

5403-
job->num_keywords = cupsParseOptions(message, job->num_keywords,
5404-
&job->keywords);
5420+
keywords = NULL;
5421+
num_keywords = cupsParseOptions(message, 0, &keywords);
5422+
5423+
for (i = 0, keyword = keywords; i < num_keywords; i ++)
5424+
{
5425+
/*
5426+
* Filter out "special" PPD keywords...
5427+
*/
5428+
5429+
if (strcmp(keyword->name, "cupsFilter") && strcmp(keyword->name, "cupsFilter2") && strcmp(keyword->name, "cupsFinishingTemplate") && strcmp(keyword->name, "cupsIPPFinishings") && strcmp(keyword->name, "cupsIPPReason") && strcmp(keyword->name, "cupsMarkerName") && strcmp(keyword->name, "cupsMaxSize") && strncmp(keyword->name, "cupsMediaQualifier", 18) && strcmp(keyword->name, "cupsMinSize") && strcmp(keyword->name, "cupsPageSizeCategory") && strcmp(keyword->name, "cupsPortMonitor") && strcmp(keyword->name, "cupsPreFilter") && strcmp(keyword->name, "cupsPrintQuality") && strcmp(keyword->name, "APPrinterPreset"))
5430+
job->num_keywords = cupsAddOption(keyword->name, keyword->value, job->num_keywords, &job->keywords);
5431+
}
5432+
5433+
cupsFreeOptions(num_keywords, keywords);
54055434
}
54065435
else
54075436
{

0 commit comments

Comments
 (0)