-
Notifications
You must be signed in to change notification settings - Fork 7.9k
ext/ldap: fix leak on port overflow check. #18645
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: PHP-8.3
Are you sure you want to change the base?
Conversation
ext/ldap/ldap.c
Outdated
@@ -994,6 +994,7 @@ PHP_FUNCTION(ldap_connect) | |||
size_t urllen = hostlen + sizeof( "ldap://:65535" ); | |||
|
|||
if (port <= 0 || port > 65535) { | |||
zval_ptr_dtor(return_value); |
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.
This doesn't "clear out" the return value, so you'll get a double free later I think.
Instead, the proper fix is probably moving the object_init_ex
and assignment to ld
further down (and then getting rid of the existing zval_ptr_dtor(return_value); under #ifdef LDAP_OPT_X_TLS_NEWCTX
Can you try to minimize the diff by not re-indenting? |
657f79b
to
890c2f0
Compare
Don't forget to remove that now-redundant |
890c2f0
to
df91d36
Compare
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.
This code is right. Maybe a test would be nice.
I just noticed there's another leak btw: on line 999 url is emalloc'd, but not all error paths free this
Test failure is legit |
3a5e835
to
fb59f66
Compare
05eb972
to
e977f2b
Compare
e977f2b
to
32a7f59
Compare
No description provided.