Skip to content

scheduler: Sanitize values for FilterNice directive#1511

Open
zdohnal wants to merge 1 commit intoOpenPrinting:masterfrom
zdohnal:nice-values
Open

scheduler: Sanitize values for FilterNice directive#1511
zdohnal wants to merge 1 commit intoOpenPrinting:masterfrom
zdohnal:nice-values

Conversation

@zdohnal
Copy link
Member

@zdohnal zdohnal commented Mar 16, 2026

We allow only values 0-19 for nice() in cupsd, but when reading the configuration this fact was not applied.

@zdohnal zdohnal requested a review from michaelrsweet March 16, 2026 13:17
Copy link

@notroj notroj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

We allow only values 0-19 for `nice()` in cupsd, but when reading the
configuration this fact was not applied.
Copy link
Member

@michaelrsweet michaelrsweet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments.

I'm somewhat ambivalent about adding a new type just for this one (rarely-used) directive; ideally the cupsd_var_t structure could be extended to include lower and upper range values, or you could just move the "FilterNice" processing to the read_cupsd_conf function.


while (*value)
{
if (!isdigit(*value++))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will increment the value pointer past the digits, then you call strtol which won't see any value and you'll just get 0.

Better to simply call strtol with an end pointer and check the range and any remaining characters. Also make sure the use long for the value...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants