-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
kdf: put back argument null checks #28204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Can you provide a plausible rationale for these? The provider context is allocated in the "new" callback and a non-null value is passed to all the other methods by the EVP layer, I am not aware of any opportunities for a NULL value in the |
Why "back"? I can't find any commit that removed them, they seem to be absent from the commits the added the respective KDFs. |
These checks were added in the various recent generated decoder PRs I done. The PR removing them (#28176) was merged yesterday. Before they were added, it was a hodgepodge where some implementations did these checks and some didn't. The decoder work changed them all to include the check because this was specifically requested by a reviewer of some of the initial effort. Now that a few checks have been removed, we're back to a less than ideal inconsistent state. The rationale is that these are a public API and we make an effort to check arguments in public APIs. I know that libcrypto does the right thing and never passes nulls to providers but that doesn't mean other callers will be so diligent. I'm aware of several providers that directly call other providers without involving libcrypto:
There is also nothing stopping an application from calling providers directly: the APIs in question are public and stable after all. Hyrum’s law is almost certainly in effect. I've raised an issue (#28202) to have a committer discussion about this. We either want them everywhere or nowhere. I don't much care which but we need to choose one way or the other and make all of the required changes. This PR represents the easier path. |
I see, thank you for the explanation. As these are public API, I'd suggest to expressly annotate the relevant arguments with |
If we're now in the C99 business, I'd prefer the attribute approach over reintroducing the checks. Let the compiler do the work (better). Essentially these become akin to C++ call by reference, which is largely avoids NPEs by having the call site syntax specify an object rather than its address, though one can of course bypass the safety with |
Can you please point me to where in the C99 standard, attributes are introduced? |
The null checks should be added. The attribute check for non-null args is definitely not universal. And we should be consistent as per Paul's comments. It significantly reduces support issues and it also helps reduce certain types of crashes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If nulll-checks are consistent across the library, then I support to add those checks here.
No description provided.