curl / Mailing Lists / curl-library / Single Mail

curl-library

Fetching https ressource, occuring memory error

From: <jan_at_dwrox.net>
Date: Tue, 14 Feb 2017 11:27:43 +0100

Hello,

I try to connect to an https ressource using libcurls easy interface.
But the program crashes on the easy_perfom() call with an illegal read
of size 1.
According to Valgrind testing on Linux, the error occurs at strncasecmp.

I tried the current release as well as older versions from Github, build
on Linux directly and on Windows using msys2 versions, but all versions
crash on the execution.

When using curl as standalone, I can connect and fetch some data (its a
GET request with parameters).

Following the output of the verbose connection:
---------------------------
* timeout on name lookup is not supported
* Trying *.*.*.*...
* TCP_NODELAY set
   % Total % Received % Xferd Average Speed Time Time Time
Current
                                  Dload Upload Total Spent Left
Speed
   0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:--
     0* Connected to domainName (*.*.*.*) port 443 (#0)
* ALPN, offering http/1.1
* Cipher selection:
ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* error setting certificate verify locations, continuing anyway:
* CAfile: LOCATION
   CApath: none
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server accepted to use http/1.1
* Server certificate:
* subject: CN=DOMAIN
* start date: ----
* expire date: ----
* subjectAltName: host "DOMAIN" matched cert's "DOMAIN"
* issuer: C=US; O=Let's Encrypt; CN=Let's Encrypt Authority X3
* SSL certificate verify result: unable to get local issuer certificate
(20), continuing anyway.

[CRASH]

---------------------------

And here is the code I am using to connect to the resource:
--------------------------------

   curl_global_init(CURL_GLOBAL_ALL);

   CURL *curl = curl_easy_init();

   if (!curl) {
     fprintf(stderr, "Could not initiale curl.");
     return -1;
   }

   curl_easy_setopt(curl, CURLOPT_NOPROGRESS, false);
   curl_easy_setopt(curl, CURLOPT_VERBOSE, true);
   curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
   curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, "*/*");
   curl_easy_setopt(curl, CURLOPT_URL,
"https://DOMAIN/urlpart1/urlpart2/request?query1=string&query2=string");
   curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&dataBuffer); //
Uses a memory buffer
   curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, callback_timestamp); //
Doenst even become called

   CURLcode requestResult;
   requestResult = curl_easy_perform(curl); // Crashes with illegal read
of size 1, not returning anything
   // Is never reached, application crash
   // Print result

   curl_easy_cleanup(curl);
   curl_global_cleanup();

-----------------------------------------

I am not sure what the exact problem is so. Am I missing to set the
request specifically to GET or something alone those lines?

Thank in advance for helpfull feedback

Jan
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2017-02-14