Skip to content

Implement GH-15483: Use C23 memset_explicit() for ZEND_SECURE_ZERO() if available #18713

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nielsdos
Copy link
Member

No description provided.

Comment on lines 492 to +495
#ifdef ZEND_WIN32
#define ZEND_SECURE_ZERO(var, size) RtlSecureZeroMemory((var), (size))
#elif defined(HAVE_MEMSET_EXPLICIT)
#define ZEND_SECURE_ZERO(var, size) memset_explicit((var), 0, (size))
Copy link
Member

Choose a reason for hiding this comment

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

Should these be reordered? I would hope that Windows also gets memset_explicit() and then it should be the preferred one IMO.

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 don't think relying on the RTL is bad. Also: we're talking about Windows, from the company that can't even make a C99 compliant compiler nor preprocessor

Copy link
Member

Choose a reason for hiding this comment

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

that can't even make a C99 compliant compiler nor preprocessor

I think this is due to VLA which have been removed from the standard since then?


Basically what I'm hoping for with the question is that we can do away with the ZEND_SECURE_ZERO macro one day and just use memset_explicit() directly everywhere.

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 think this is due to VLA which have been removed from the standard since then?

No, I was referring (non-limitative) to horrors like https://learn.microsoft.com/en-us/cpp/build/reference/experimental-preprocessor?view=msvc-170

Basically what I'm hoping for with the question is that we can do away with the ZEND_SECURE_ZERO macro one day and just use memset_explicit() directly everywhere.

I get that, but it would take years before we can bump to C23 anyway

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.

Use C23 memset_explicit() for ZEND_SECURE_ZERO() if available
2 participants