Skip to content

Fix the signature of CRYPT_EX_dup - #2986

Closed
bernd-edlinger wants to merge 2 commits into
openssl:masterfrom
bernd-edlinger:fix_params_of_CRYPTO_EX_dup
Closed

bernd-edlinger wants to merge 2 commits into
openssl:masterfrom
bernd-edlinger:fix_params_of_CRYPTO_EX_dup

Conversation

@bernd-edlinger

Copy link
Copy Markdown
Member

This fixes a strict aliasing issue in ui_dup_method_data.

And fix the error handling in CRYPTO_dup_ex_data.

I have split the error handling fix in an extra commit,
as the function signature can probably only be changed
in the master branch, while the error handling should
be fixed in 1.1.0 as well. I will need another PR for 1.0.2.

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

Comment thread doc/man3/CRYPTO_get_ex_new_index.pod Resolved
@bernd-edlinger
bernd-edlinger force-pushed the fix_params_of_CRYPTO_EX_dup branch from 3f735d4 to ff8ff37 Compare March 19, 2017 16:18
@richsalz

Copy link
Copy Markdown
Contributor

sigh. and if we don't fix the API, what's the risk? we really hate changing API's unless it's a serious bug being fixed.

Comment thread include/openssl/crypto.h Resolved
@bernd-edlinger

Copy link
Copy Markdown
Member Author

In theory the compiler can assume that *pptr in ui_dup_method_data
is not an alias of ptr in CRYPTO_dup_ex_data, because char * and void *
can not alias, but I would not fix it in 1.1.0, only in master.

@richsalz

Copy link
Copy Markdown
Contributor

As @levitte points out, it is an API change and therefore can't go in master now since that's going to be 1.1.1 So this will have to wait, likely until 2018.

@richsalz richsalz added the hold label Mar 19, 2017
@richsalz

Copy link
Copy Markdown
Contributor

Not now, no. WE committed to our next release being 1.1.1 which is ABI compatible.

@bernd-edlinger

Copy link
Copy Markdown
Member Author

Ok, I see, actually it is ok for the strict aliasing to cast a void **
to a void* as long as you cast it back to a void **

@levitte

levitte commented Mar 19, 2017

Copy link
Copy Markdown
Member

Are you expecting all implementations to start casting srcp to void ** all of a sudden?

@bernd-edlinger

Copy link
Copy Markdown
Member Author

aehm, maybe they read the documentation :-)

@bernd-edlinger

Copy link
Copy Markdown
Member Author

I could write something like:
The B<from_d> parameter needs to be cast to a B<void **pptr>
as the API has currently the wrong signature; that will be changed in a
future version. The B<*pptr> is a pointer to the source exdata.
When the dup_func() returns, the value in B<*pptr> is copied to the
destination ex_data.

@bernd-edlinger
bernd-edlinger force-pushed the fix_params_of_CRYPTO_EX_dup branch from ff8ff37 to b94daeb Compare March 20, 2017 16:31
@bernd-edlinger

Copy link
Copy Markdown
Member Author

rebased, and waiting for 1.2.0 now...

@levitte levitte added the 1.2.0 label Mar 20, 2017
@levitte levitte added this to the 1.2.0 milestone Mar 20, 2017
infinityhacks pushed a commit to infinityhacks/openssl that referenced this pull request May 9, 2017
@richsalz richsalz removed the hold label May 6, 2018
@richsalz richsalz modified the milestones: 1.2.0, Post 1.1.0 May 6, 2018
@richsalz richsalz modified the milestones: Post 1.1.0, Assessed May 6, 2018
@bernd-edlinger

Copy link
Copy Markdown
Member Author

So this will have to wait, likely until 2018.

By the way it is 2020 now.

This fixes a strict aliasing issue in ui_dup_method_data.

The parameter type of CRYPTO_EX_dup's from_d parameter
is in fact void **, since it points to a pointer.

This function is rarely used, therefore fix the param type
although that may be considered an API breaking change.
Comment thread doc/man3/CRYPTO_get_ex_new_index.pod Resolved
@levitte levitte added approval: review pending This pull request needs review by a committer branch: master Applies to master branch labels May 22, 2020
@levitte

levitte commented May 22, 2020

Copy link
Copy Markdown
Member

This is ok for master. Considering that the current documentation says that the passed argument should really be a void **, and that the API will be fixed in the future, 3.0 is as good a future as any.

@levitte

levitte commented May 22, 2020

Copy link
Copy Markdown
Member

When history section has been added, this should be approvable

@levitte levitte added approval: done This pull request has the required number of approvals and removed approval: review pending This pull request needs review by a committer labels May 22, 2020
@levitte

levitte commented May 22, 2020

Copy link
Copy Markdown
Member

Just to be a bit extra explicit, I approve this for master only.

@openssl-machine

Copy link
Copy Markdown
Collaborator

24 hours has passed since 'approval: done' was set, but as this PR has been updated in that time the label 'approval: ready to merge' is not being automatically set. Please review the updates and set the label manually.

openssl-machine pushed a commit that referenced this pull request May 23, 2020
This fixes a strict aliasing issue in ui_dup_method_data.

The parameter type of CRYPTO_EX_dup's from_d parameter
is in fact void **, since it points to a pointer.

This function is rarely used, therefore fix the param type
although that may be considered an API breaking change.

Reviewed-by: Richard Levitte <[email protected]>
(Merged from #2986)
@bernd-edlinger

Copy link
Copy Markdown
Member Author

Merged to master as 712e8de

@kaduk

kaduk commented Jun 3, 2020

Copy link
Copy Markdown
Contributor

Of course, void** does not have the void* nature of "compatible with any pointer type of same constedness/etc", so implementations will have to cast on assignment to their local type to get a warning-free build. But that's not particularly hard to do.

alex-eri added a commit to alex-eri/uradius that referenced this pull request Nov 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approval: done This pull request has the required number of approvals branch: master Applies to master branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants