Skip to content

Commit

Permalink
scheduler/cert.c: Fix string comparison (fixes CVE-2022-26691)
Browse files Browse the repository at this point in the history
The previous algorithm didn't expect the strings can have a different
length, so one string can be a substring of the other and such substring
was reported as equal to the longer string.
  • Loading branch information
zdohnal committed May 26, 2022
1 parent 498fd9f commit de4f8c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CHANGES - OpenPrinting CUPS 2.4.1 - 2022-01-27
Changes in CUPS v2.4.2 (TBA)
----------------------------

- Fixed certificate strings comparison for Local authorization (CVE-2022-26691)
- The `cupsFileOpen` function no longer opens files for append in read-write
mode (Issue #291)
- The cupsd daemon removed processing temporary queue (Issue #364)
Expand Down
9 changes: 8 additions & 1 deletion scheduler/cert.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,5 +444,12 @@ ctcompare(const char *a, /* I - First string */
b ++;
}

return (result);
/*
* The while loop finishes when *a == '\0' or *b == '\0'
* so after the while loop either both *a and *b == '\0',
* or one points inside a string, so when we apply logical OR on *a,
* *b and result, we get a non-zero return value if the compared strings don't match.
*/

return (result | *a | *b);
}

0 comments on commit de4f8c1

Please sign in to comment.