Skip to content

md5, sha1, openssl - using zend_bin2hex instead of local helper - #23819

Merged
Girgias merged 1 commit into
php:masterfrom
adapik:md5-sha1-use-zend-bin2hex
Sep 21, 2026
Merged

Girgias merged 1 commit into
php:masterfrom
adapik:md5-sha1-use-zend-bin2hex

Conversation

@adapik

@adapik adapik commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Another follow-up for #21724 — found a couple more places using a local hex-encode helper instead of zend_bin2hex(). Changes are basically the same shape as #21832 did for the ext/hash callers, just for md5()/sha1() and the two ext/openssl spots (openssl_digest(), openssl_x509_fingerprint()) that never depended on ext/hash so #21832 didn't touch them.

@Girgias Girgias left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

Comment thread ext/standard/md5.c
/* Some callers (e.g. ext/soap's WSDL cache key) memcpy() the whole
buffer including this terminator, so it must still be written here;
zend_bin2hex() itself does not null-terminate. */
md5str[len * 2] = '\0';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This would probably be nicer if zend_bin2hex() either returned the end pointer or the length of data written.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I generally agree it's a good suggestion, but it doesn't directly relate to the changes in this PR - the same pattern exists in other places where it was substituted previously. I'd rather implement this suggestion in a separate PR and for all the places.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd rather implement this suggestion in a separate PR and for all the places.

Yes, I didn't mean to say that it should be done as part of this PR. I just noticed when looking at this one for a possible follow-up.

@Girgias
Girgias merged commit 39d8aee into php:master Sep 21, 2026
18 checks passed
@LamentXU123

Copy link
Copy Markdown
Member

Thank you. Plus, several days ago I came across some code in other extensions that implement hex2bin itself. I think this might be possible follow-up. #23821

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.

4 participants