FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Harden adding error text. by bob-beck · Pull Request #32562 · openssl/openssl · GitHub

Harden adding error text. - #32562

Draft
bob-beck wants to merge 20 commits into
openssl:masterfrom
bob-beck:err_add_error_vdata_considered_harmful
Draft

Harden adding error text. #32562
bob-beck wants to merge 20 commits into
openssl:masterfrom
bob-beck:err_add_error_vdata_considered_harmful

Conversation

bob-beck commented Aug 28, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

I really loved the 90's - the music was great, I was bulletproof, my middle name was DANGER, as
were most of the public API's in C code.

Sadly I'm now much older and feel a lot less bulletproof and tolerant of danger. 35 years of
C programming and surviving a head on collision does stuff to you.

Let's mark the printf style error appenders with the printf attribute, and then fix the things
where we were sort of abusing them. This includes a large sweep at the end to catch everything
in CI I couldn't directly catch. Of note one bug was noticed while doing this where we printed
a public key length when erroring about a private key.

Then there is ERR_add_error_data() and ERR_add_error_vdata() - Back in the 90's
public API that that bravely walked a va_list with an integer provided length into danger without using the usual "stop at a terminating NULL" was just fine (it was the best of times). Today this just seems to be a footgun waiting to happen.

Let's deprecate these strange varargs "append a string" functions, and use an internal replacement
that is safer since it just uses printf. I dont' believe it needs to be public as external callers don't really
need this, they can build up an error string themselves and add it with the existing public api.

Checklist
  • documentation is added or updated
  • tests are added or updated

ERR_set_error() and ERR_vset_error() take a printf(3) style format
string, but carried no format attribute, so nothing verified the
arguments supplied at ERR_raise_data() call sites.

Add the attribute so we keep this clean. Upon adding the attribute
four calls showed up passing a non-literal string as the format,
three of them the return value of gai_strerror(). Pass the string as
an argument to "%s" instead.
Each of these sites raised an error and then immediately appended a
single string to it.  ERR_raise_data() does both in one call, and its
arguments are checked by the compiler.

No functional change.
poll_for_response() formatted the offending value into a local buffer
and appended it to the error it had just raised.  ERR_raise_data()
does both in one call, with the format checked by the compiler.

No functional change.
Eleven error paths raised a reason and jumped to bad_str, whose only
job was to append the offending string to whichever error had just
been raised.  ERR_raise_data() carries the string with the reason.

No functional change.
Appends printf(3) formatted text to the data of the most recent error,
as ERR_add_error_data() does, without the hand-written argument count.
bob-beck changed the title Err add error vdata considered harmful Harden adding error text. Aug 28, 2026
openssl-ci-bot Bot added the approval: review pending This pull request needs review by a committer label Aug 28, 2026
bob-beck force-pushed the err_add_error_vdata_considered_harmful branch 4 times, most recently from f495c02 to c9af5d2 Compare August 28, 2026 15:00
bob-beck force-pushed the err_add_error_vdata_considered_harmful branch from c9af5d2 to 8ff9f27 Compare August 28, 2026 15:09
github-actions Bot added the severity: fips change The pull request changes FIPS provider sources label Aug 28, 2026
When the private key length is not what we expect don't
print the public key length.
bob-beck force-pushed the err_add_error_vdata_considered_harmful branch 2 times, most recently from 7ab746a to 6d6c16c Compare August 28, 2026 15:25
bob-beck force-pushed the err_add_error_vdata_considered_harmful branch from 6d6c16c to b541554 Compare August 28, 2026 15:38
bob-beck added the extended tests Run extended tests in CI label Aug 28, 2026
bob-beck self-assigned this Aug 28, 2026
bob-beck requested a review from esyr August 28, 2026 15:53
bob-beck closed this Aug 28, 2026
bob-beck reopened this Aug 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approval: review pending This pull request needs review by a committer extended tests Run extended tests in CI severity: fips change The pull request changes FIPS provider sources

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL