From 4cf91916c809844c71576e5d03b441f8cb3b6276 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Fri, 5 Nov 2021 02:38:27 -0400 Subject: [PATCH] Fix curl crash when DNS does not resolve. --- dep/Makefile | 2 +- src/network.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/dep/Makefile b/dep/Makefile index 8eed084f..f0ab8231 100755 --- a/dep/Makefile +++ b/dep/Makefile @@ -131,7 +131,7 @@ curl-7.79.1: rm curl-7.79.1.tar.gz CURL_FLAGS += --enable-symbol-hiding --enable-shared=no -CURL_FLAGS += --enable-http --disable-ftp --disable-file --disable-ldap --disable-ldaps --disable-rtsp --enable-proxy --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smb --disable-smtp --disable-gopher --disable-mqtt --disable-manual --disable-threaded-resolver --disable-pthreads --disable-verbose --disable-sspi --disable-ntlm --disable-ntlm-wb --disable-tls-srp --disable-unix-sockets --disable-doh --disable-mime --disable-dateparse --disable-netrc --disable-progress-meter --disable-alt-svc +CURL_FLAGS += --enable-http --disable-ftp --disable-file --disable-ldap --disable-ldaps --disable-rtsp --enable-proxy --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smb --disable-smtp --disable-gopher --disable-mqtt --disable-manual --enable-threaded-resolver --enable-pthreads --disable-verbose --disable-sspi --disable-ntlm --disable-ntlm-wb --disable-tls-srp --disable-unix-sockets --disable-doh --disable-mime --disable-dateparse --disable-netrc --disable-progress-meter --disable-alt-svc CURL_FLAGS += --without-hyper --without-zlib --without-brotli --without-zstd --without-libpsl --without-libgsasl --without-libssh2 --without-librtmp --without-winidn --without-libidn2 --without-nghttp2 --without-ngtcp2 --without-nghttp3 --without-quiche CURL_FLAGS += --with-ssl="$(DEP_PATH)" diff --git a/src/network.cpp b/src/network.cpp index 833fff63..0fcbf24f 100644 --- a/src/network.cpp +++ b/src/network.cpp @@ -27,6 +27,11 @@ static CURL* createCurl() { // 15 second timeout for requests curl_easy_setopt(curl, CURLOPT_TIMEOUT, 15); + // If curl can't resolve a DNS entry, it sends a signal to interrupt the process. + // However, since we use curl on non-main thread, this crashes the application. + // So tell curl not to signal. + curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); + std::string caPath = asset::system("cacert.pem"); curl_easy_setopt(curl, CURLOPT_CAINFO, caPath.c_str());