|
| 1 | +#include "../../../../../library-tests/string_concat/stl.h" |
| 2 | + |
| 3 | +namespace std{ |
| 4 | + struct CURL {}; |
| 5 | + typedef CURL curl; |
| 6 | + enum curl_constant{ |
| 7 | + CURLOPT_URL, |
| 8 | + CURLOPT_SSL_VERIFYHOST, |
| 9 | + CURLOPT_SSL_VERIFYPEER |
| 10 | + }; |
| 11 | + |
| 12 | + CURL *curl_easy_init(); |
| 13 | + void curl_easy_cleanup(CURL *handle); |
| 14 | + void curl_easy_perform(CURL *handle); |
| 15 | + void curl_easy_setopt(CURL *handle, curl_constant param, int p); |
| 16 | + void curl_easy_setopt(CURL *handle, curl_constant param, char* p); |
| 17 | +} |
| 18 | + |
| 19 | + |
| 20 | +using namespace std; |
| 21 | +char host[] = "codeql.com"; |
| 22 | + |
| 23 | +void bad(void) { |
| 24 | + std::unique_ptr<CURL> curl = std::unique_ptr<CURL>(curl_easy_init()); |
| 25 | + curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYPEER, 0); |
| 26 | + curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYHOST, 0); |
| 27 | + curl_easy_setopt(curl.get(), CURLOPT_URL, host); |
| 28 | + curl_easy_perform(curl.get()); |
| 29 | +} |
| 30 | + |
| 31 | +void good(void) { |
| 32 | + std::unique_ptr<CURL> curl = std::unique_ptr<CURL>(curl_easy_init()); |
| 33 | + curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYPEER, 2); |
| 34 | + curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYHOST, 2); |
| 35 | + curl_easy_setopt(curl.get(), CURLOPT_URL, host); |
| 36 | + curl_easy_perform(curl.get()); |
| 37 | +} |
| 38 | + |
| 39 | +int main(int c, char** argv){ |
| 40 | + bad(); |
| 41 | + good(); |
| 42 | +} |
| 43 | + |
0 commit comments