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

SSL handshake segfaults if BIO_do_connnect don't connect #2976

Closed
sha0coder opened this issue Dec 4, 2019 · 2 comments
Closed

SSL handshake segfaults if BIO_do_connnect don't connect #2976

sha0coder opened this issue Dec 4, 2019 · 2 comments
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@sha0coder
Copy link
Contributor

sha0coder commented Dec 4, 2019

V version: V 0.1.23 f0f62f6
OS: archlinux
What did you do? http.get("https://127.0.0.1")
What did you see instead? SIGSEGV

Solution:
on v/vlib/http/backend_nix.v ssl_do()

Dont do the handshake if BIO_do_connect fails.

res = C.BIO_do_connect(web)
if res != 1 {
return error('cannot connect')
}
res = C.BIO_do_handshake(web)

Crash:
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7ccd680 in ?? () from /usr/lib/libcrypto.so.1.1
(gdb) bt
#0 0x00007ffff7ccd680 in ?? () from /usr/lib/libcrypto.so.1.1
#1 0x00007ffff7cd0ef4 in BIO_connect () from /usr/lib/libcrypto.so.1.1
#2 0x00007ffff7cd63af in ?? () from /usr/lib/libcrypto.so.1.1
#3 0x00007ffff7cd6690 in ?? () from /usr/lib/libcrypto.so.1.1
#4 0x00007ffff7cd450a in ?? () from /usr/lib/libcrypto.so.1.1
#5 0x00007ffff7cd3534 in ?? () from /usr/lib/libcrypto.so.1.1
#6 0x00007ffff7cd3a13 in BIO_write () from /usr/lib/libcrypto.so.1.1
#7 0x00007ffff7cd1d62 in ?? () from /usr/lib/libcrypto.so.1.1
#8 0x00007ffff7cd3ee6 in BIO_ctrl () from /usr/lib/libcrypto.so.1.1
#9 0x00007ffff7f4bd5e in ?? () from /usr/lib/libssl.so.1.1
#10 0x00007ffff7f50800 in ?? () from /usr/lib/libssl.so.1.1
#11 0x00007ffff7f4b252 in ?? () from /usr/lib/libssl.so.1.1
#12 0x00007ffff7f37136 in SSL_do_handshake () from /usr/lib/libssl.so.1.1
#13 0x00007ffff7f1c46b in ?? () from /usr/lib/libssl.so.1.1
#14 0x00007ffff7cd3ee6 in BIO_ctrl () from /usr/lib/libcrypto.so.1.1
#15 0x000055555556cc6e in http__Request_ssl_do ()
#16 0x000055555556e7a8 in http__Request_method_and_url_to_response ()
#17 0x000055555556e074 in http__Request_do ()
#18 0x000055555556d1af in http.get ()

@sha0coder sha0coder added the Bug This tag is applied to issues which reports bugs. label Dec 4, 2019
@sha0coder sha0coder changed the title SSL to any IP segfaults ie: http.get("https://127.0.0.1") SSL handshake segfaults if BIO_do_connnect don't connect Dec 8, 2019
@sha0coder
Copy link
Contributor Author

simply add this between the connect and the handshake:
if res != 1 {
return error('cannot connect')
}

@sha0coder
Copy link
Contributor Author

PR applied

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs.
Projects
None yet
Development

No branches or pull requests

1 participant