From: Jens Axboe Date: Thu, 16 Aug 2018 15:20:43 +0000 (-0600) Subject: Merge branch 'http_older_openssl' of https://github.com/ddiss/fio X-Git-Tag: fio-3.9~31 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=8822b8271b7d110a2b07795d7d25ad5677bc05c4;hp=35e2d88fad2151f272af60babb5e6c98922d0bcd Merge branch 'http_older_openssl' of https://github.com/ddiss/fio * 'http_older_openssl' of https://github.com/ddiss/fio: engines/http: support openssl < 1.1.0 configure: use pkg-config to detect libcurl & openssl --- diff --git a/configure b/configure index 103ea945..0637b105 100755 --- a/configure +++ b/configure @@ -1573,26 +1573,11 @@ print_config "IPv6 helpers" "$ipv6" if test "$http" != "yes" ; then http="no" fi -cat > $TMPC << EOF -#include -#include - -int main(int argc, char **argv) -{ - CURL *curl; - HMAC_CTX *ctx; - - curl = curl_easy_init(); - curl_easy_cleanup(curl); - - ctx = HMAC_CTX_new(); - HMAC_CTX_reset(ctx); - HMAC_CTX_free(ctx); - return 0; -} -EOF -if test "$disable_http" != "yes" && compile_prog "" "-lcurl -lssl -lcrypto" "curl"; then - LIBS="-lcurl -lssl -lcrypto $LIBS" +if test "$disable_http" != "yes" && $(pkg-config --exists libcurl openssl); then + if $(pkg-config --atleast-version=1.1.0 openssl); then + output_sym "CONFIG_HAVE_OPAQUE_HMAC_CTX" + fi + LIBS="$(pkg-config --libs libcurl openssl) $LIBS" http="yes" fi print_config "http engine" "$http" diff --git a/engines/http.c b/engines/http.c index d3fdba82..979573a8 100644 --- a/engines/http.c +++ b/engines/http.c @@ -205,14 +205,25 @@ static char *_gen_hex_sha256(const char *p, size_t len) } static void _hmac(unsigned char *md, void *key, int key_len, char *data) { +#ifndef CONFIG_HAVE_OPAQUE_HMAC_CTX + HMAC_CTX _ctx; +#endif HMAC_CTX *ctx; unsigned int hmac_len; +#ifdef CONFIG_HAVE_OPAQUE_HMAC_CTX ctx = HMAC_CTX_new(); +#else + ctx = &_ctx; +#endif HMAC_Init_ex(ctx, key, key_len, EVP_sha256(), NULL); HMAC_Update(ctx, (unsigned char*)data, strlen(data)); HMAC_Final(ctx, md, &hmac_len); +#ifdef CONFIG_HAVE_OPAQUE_HMAC_CTX HMAC_CTX_free(ctx); +#else + HMAC_CTX_cleanup(ctx); +#endif } static int _curl_trace(CURL *handle, curl_infotype type,