-
Notifications
You must be signed in to change notification settings - Fork 8k
Audit zend_ini_string() and related functions #21146
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
Girgias
wants to merge
13
commits into
php:master
Choose a base branch
from
Girgias:ini-audit-zend_ini_string
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
8da598e
zend_highlight: mark char* cont
Girgias 338d795
Audit zend_ini_string usage
Girgias 0cb5a69
Audit INI_STR
Girgias 5d4859e
Audit INI_ORIG_BOOL
Girgias 2d617a6
Update definitions of INI_BOOL macros
Girgias 379e437
zend_ini: mark zend_ini_string{_ex} as returning a const char*
Girgias 6fc33a0
Add new literal ini API and remove the INI_*() macros
Girgias 5c9dc5e
Remove INI_ORIG_* APIs as they are unused
Girgias cf2caad
Address review comments
Girgias bcef0ec
revert marking sendmail_cmd as const
Girgias 86293d4
Add length check, as it turns out the non _ex version returns an empt…
Girgias 8565752
Nits
Girgias a59fa1c
Upgrading
Girgias File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -880,16 +880,16 @@ static long php_openssl_load_stream_cafile(X509_STORE *cert_store, const char *c | |
| static zend_result php_openssl_enable_peer_verification(SSL_CTX *ctx, php_stream *stream) /* {{{ */ | ||
| { | ||
| zval *val = NULL; | ||
| char *cafile = NULL; | ||
| char *capath = NULL; | ||
| const char *cafile = NULL; | ||
| const char *capath = NULL; | ||
| php_openssl_netstream_data_t *sslsock = (php_openssl_netstream_data_t*)stream->abstract; | ||
|
|
||
| GET_VER_OPT_STRING("cafile", cafile); | ||
| GET_VER_OPT_STRING("capath", capath); | ||
|
|
||
| if (cafile == NULL) { | ||
| cafile = zend_ini_string("openssl.cafile", sizeof("openssl.cafile")-1, 0); | ||
| cafile = strlen(cafile) ? cafile : NULL; | ||
| const zend_string *cafile_str = zend_ini_str_literal("openssl.cafile"); | ||
| cafile = ZSTR_LEN(cafile_str) ? ZSTR_VAL(cafile_str) : NULL; | ||
| } else if (!sslsock->is_client) { | ||
| /* Servers need to load and assign CA names from the cafile */ | ||
| STACK_OF(X509_NAME) *cert_names = SSL_load_client_CA_file(cafile); | ||
|
|
@@ -902,8 +902,8 @@ static zend_result php_openssl_enable_peer_verification(SSL_CTX *ctx, php_stream | |
| } | ||
|
|
||
| if (capath == NULL) { | ||
| capath = zend_ini_string("openssl.capath", sizeof("openssl.capath")-1, 0); | ||
| capath = strlen(capath) ? capath : NULL; | ||
| const zend_string *capath_str = zend_ini_str_literal("openssl.capath"); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
| capath = ZSTR_LEN(capath_str) ? ZSTR_VAL(capath_str) : NULL; | ||
| } | ||
|
|
||
| if (cafile || capath) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I feel this should be
zend_ini_string_literal, since you don't actually use the stored length for further processing (i.e. OpenSSL takes a NUL-terminated C string).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.
The issue is that this leads to calling to
zend_ini_strwhich returns an empty string if the INI setting exists, but the current code does thestrlen()check to determine if it is an empty string or not and sets it back toNULLif so. And I don't want to change the behaviour of now sometimes passing an empty string to openssl.