Prevent cert creation failure on leap day #5643
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
http_sspi_make_credentials
function incups/tls-sspi.c
has a leap year bug.cups/cups/tls-sspi.c
Lines 1968 to 1973 in bc5060a
This will fail if the code is executed on Feb 29th of a leap year (of which 2020 is the next one), unless the
years
being added also results inet.wYear
being a leap year. In other words,2020-02-29
+1 year
would result in2021-02-29
, which does not exist. In this case,CertCreateSelfSignCertificate
will fail.The attached PR checks for this condition, and adjusts such dates back one day to February 28th, which is a reasonable and common practice.
Please be sure this gets merged and highlighted in the release notes. Those that rely on this code path will want to have fully deployed such code well before leap day 2020. Thanks.