Skip to content

gh-111178: fix UBSan failures in Modules/_ssl/cert.c #129088

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

Merged
merged 1 commit into from
Jan 30, 2025

Conversation

picnixz
Copy link
Member

@picnixz picnixz commented Jan 20, 2025

Py_RETURN_NOTIMPLEMENTED;
}
/* only support == and != */
if ((op != Py_EQ) && (op != Py_NE)) {
Py_RETURN_NOTIMPLEMENTED;
}
cmp = X509_cmp(self->cert, ((PySSLCertificate*)other)->cert);
cmp = X509_cmp(self->cert, ((PySSLCertificate*)rhs)->cert);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cmp = X509_cmp(self->cert, ((PySSLCertificate*)rhs)->cert);
cmp = X509_cmp(self->cert, _PySSLCertificate_CAST(rhs)->cert);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've left out fast casts for which the input has already been checked so that if the macro is one day converted to a function with explicit checks, we don't double checks those

@encukou encukou merged commit 9bc8c5f into python:main Jan 30, 2025
44 checks passed
@picnixz picnixz deleted the fix/ubsan/ssl-111178 branch February 2, 2025 21:51
srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this pull request Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants