Skip to content
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

Wrong Error Check position in function SSL_get_peer_certificate() #944

Closed
lc3412 opened this issue Sep 19, 2018 · 2 comments · Fixed by #1037
Closed

Wrong Error Check position in function SSL_get_peer_certificate() #944

lc3412 opened this issue Sep 19, 2018 · 2 comments · Fixed by #1037
Labels
Milestone

Comments

@lc3412
Copy link

lc3412 commented Sep 19, 2018

Hi,
Function SSL_get_peer_certificate() returns a pointer to an X509 certificate on success or NULL on error. However, the function SSL_get_peer_certificate() in irssi/src/core/network-openssl.c didn't check the return value is NULL or not, before passing the return value as an argument to the function X509_get_X509_PUBKEY(). See the following details:

screenshot from 2018-09-19 16-08-57

=================================================================================

X509_get_X509_PUBKEY() doesn't check the argument which is the return value of function SSL_get_peer_certificate() is NULL or not before using it.

Ref: https://github.com/openssl/openssl/blob/master/crypto/x509/x509_set.c
screenshot from 2018-09-19 16-13-47

=================================================================================

Anyhow, the safest behavior is checking the return value of function SSL_get_peer_certificate() first , then passing the return value as an argument to function X509_get_X509_PUBKEY(). See the following details:

cert = SSL_get_peer_certificate(chan->ssl);
if (cert == NULL) {
g_warning("TLS server supplied no certificate");
ret = 0;
goto done;
}
pubkey = X509_get_X509_PUBKEY(cert);

=================================================================================

Chi Li, Zuxing Gu, Jiecheng Wu

@ailin-nemui
Copy link
Contributor

@lc3412 please improve your issue reporting by using github's source code links instead of screenshots

example:
https://github.com/irssi/irssi/blob/a7af259dd1ded503460458bf8042c47060fa153d/src/core/network-openssl.c#L857-L863

also code block your examples with

```

while you're at it, why not submit Pull Requests fixing the issue instead?

@lc3412
Copy link
Author

lc3412 commented Sep 19, 2018

Thanks for your suggestion. I will submit PR as soon as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants