Skip to content

Instantly share code, notes, and snippets.

@stephenmathieson
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephenmathieson/12647b3caad72be5c911 to your computer and use it in GitHub Desktop.
Save stephenmathieson/12647b3caad72be5c911 to your computer and use it in GitHub Desktop.
curl over https leaking?
$ valgrind ./test
==17475== Memcheck, a memory error detector
==17475== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==17475== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==17475== Command: ./test
==17475==
==17475== Conditional jump or move depends on uninitialised value(s)
==17475== at 0x615D1D5: gnutls_session_get_data (in /usr/lib/x86_64-linux-gnu/libgnutls.so.26.21.8)
==17475== by 0x4E69125: ??? (in /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4.2.0)
==17475== by 0x4E6971D: ??? (in /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4.2.0)
==17475== by 0x4E69A24: Curl_gtls_connect (in /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4.2.0)
==17475== by 0x4E6A0B8: Curl_ssl_connect (in /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4.2.0)
==17475== by 0x4E43A1F: Curl_http_connect (in /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4.2.0)
==17475== by 0x4E545E9: Curl_protocol_connect (in /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4.2.0)
==17475== by 0x4E54899: Curl_setup_conn (in /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4.2.0)
==17475== by 0x4E54943: Curl_connect (in /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4.2.0)
==17475== by 0x4E5BBA0: ??? (in /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4.2.0)
==17475== by 0x400978: main (in /home/stephen/repos/littlstar/curltest/test)
==17475==
200
==17475==
==17475== HEAP SUMMARY:
==17475== in use at exit: 3,952 bytes in 48 blocks
==17475== total heap usage: 1,170,405 allocs, 1,170,357 frees, 63,416,526 bytes allocated
==17475==
==17475== LEAK SUMMARY:
==17475== definitely lost: 0 bytes in 0 blocks
==17475== indirectly lost: 0 bytes in 0 blocks
==17475== possibly lost: 0 bytes in 0 blocks
==17475== still reachable: 3,952 bytes in 48 blocks
==17475== suppressed: 0 bytes in 0 blocks
==17475== Rerun with --leak-check=full to see details of leaked memory
==17475==
==17475== For counts of detected and suppressed errors, rerun with: -v
==17475== Use --track-origins=yes to see where uninitialised values come from
==17475== ERROR SUMMARY: 2 errors from 1 contexts (suppressed: 2 from 2)
#include <stdio.h>
#include <curl/curl.h>
size_t
callback(void *x, size_t size, size_t nmemb, void *y) {
return size * nmemb;
}
int
main(){
CURL *curl;
long status;
curl = curl_easy_init();
if (!curl) return 1;
curl_easy_setopt(curl, CURLOPT_URL, "https://google.com/");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, NULL);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &status);
printf("%ld\n", status);
curl_easy_cleanup(curl);
curl_global_cleanup();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment