From 815497495eee92e028320ef96dc5b7ec13d85216 Mon Sep 17 00:00:00 2001 From: Nelson Billing Date: Fri, 21 Feb 2020 15:54:49 -0800 Subject: Make LibcurlWrapper support static linking. - Didn't used to support statically linked libcurl, now it does (like HttpUpload does). Change-Id: Ic014548225b129f0c1c9ffe6a671f5bd2352b6e6 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2068947 Reviewed-by: Ivan Penkov Reviewed-by: Joshua Peraza --- src/common/linux/libcurl_wrapper.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/common/linux/libcurl_wrapper.cc b/src/common/linux/libcurl_wrapper.cc index d935174b..e96c2038 100644 --- a/src/common/linux/libcurl_wrapper.cc +++ b/src/common/linux/libcurl_wrapper.cc @@ -173,7 +173,19 @@ bool LibcurlWrapper::SendSimplePostRequest(const string& url, } bool LibcurlWrapper::Init() { - curl_lib_ = dlopen("libcurl.so", RTLD_NOW); + // First check to see if libcurl was statically linked: + curl_lib_ = dlopen(nullptr, RTLD_NOW); + if (curl_lib_ && + (!dlsym(curl_lib_, "curl_easy_init") || + !dlsym(curl_lib_, "curl_easy_setopt"))) { + // Not statically linked, try again below. + dlerror(); // Clear dlerror before attempting to open libraries. + dlclose(curl_lib_); + curl_lib_ = nullptr; + } + if (!curl_lib_) { + curl_lib_ = dlopen("libcurl.so", RTLD_NOW); + } if (!curl_lib_) { curl_lib_ = dlopen("libcurl.so.4", RTLD_NOW); } -- cgit v1.2.1