check the return value of SSL_get_ex_data()#8268
Closed
x2018 wants to merge 3 commits into
Closed
Conversation
bagder
reviewed
Jan 13, 2022
| sockindex_ptr = (curl_socket_t*) SSL_get_ex_data(ssl, sockindex_idx); | ||
| if(!conn || !data || !sockindex_ptr) | ||
| return 0; | ||
|
|
Member
There was a problem hiding this comment.
If no error has been returned before, can this really happen?
And if this can happen, doesn't it signify a major error somewhere to call for everything to get closed down?
Contributor
Author
|
Yes, it looks like this can happen as Line 4549 in 84853d9 void type and inside it does not check the return value of SSL_set_ex_data, while SSL_set_ex_data may fail because of some internal errors.To catch the error in time, I will change the signature of ossl_associate_connection and add several checks these days.
|
…ck to catch the internal errors of SSL_set_ex_data or SSL_get_ex_new_index in time
Contributor
Author
|
I updated the signature of ossl_associate_connection and added several checks. And I retain the usage of Curl_ssl->associate_connection() in vtls.c as before. I am not sure whether these changes make sense. Thank you for taking the time to review this PR. |
bagder
approved these changes
Jan 23, 2022
Member
|
Thanks! |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
check the return value of
SSL_get_ex_data()to prevent potential NULL dereference.SSL_set_ex_data()called byossl_associate_connection()may fail, so it is better to check the return value fromSSL_get_ex_data(), especiallydatawhich will be dereferenced in the following code. And thoughsockindexseems meaningless inCurl_ssl_getsessionid()orCurl_ssl_addsessionid()?