diff options
author | Dan Fandrich <dan@coneharvesters.com> | 2014-05-01 11:00:30 +0200 |
---|---|---|
committer | Dan Fandrich <dan@coneharvesters.com> | 2014-05-01 11:00:30 +0200 |
commit | c3031073457c9406fe79dcd40cc503c8eb22bea5 (patch) | |
tree | 016ee8a72cdd52789a42182598f9b04e132db4b0 /tests | |
parent | 3d77d013e1b55aab711683eb90b72bad651efbeb (diff) |
test585: Fixed NULL pointer dereference in fopen
Diffstat (limited to 'tests')
-rw-r--r-- | tests/libtest/lib500.c | 71 |
1 files changed, 36 insertions, 35 deletions
diff --git a/tests/libtest/lib500.c b/tests/libtest/lib500.c index b1c53fac9..4d622084e 100644 --- a/tests/libtest/lib500.c +++ b/tests/libtest/lib500.c @@ -91,43 +91,44 @@ int test(char *URL) res = curl_easy_perform(curl); if(!res) { - FILE *moo; res = curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP, &ipstr); - moo = fopen(libtest_arg2, "wb"); - if(moo) { - double time_namelookup; - double time_connect; - double time_pretransfer; - double time_starttransfer; - double time_total; - fprintf(moo, "IP: %s\n", ipstr); - curl_easy_getinfo(curl, CURLINFO_NAMELOOKUP_TIME, &time_namelookup); - curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME, &time_connect); - curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME, &time_pretransfer); - curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME, - &time_starttransfer); - curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &time_total); - - /* since the timing will always vary we only compare relative differences - between these 5 times */ - if(time_namelookup > time_connect) { - fprintf(moo, "namelookup vs connect: %f %f\n", - time_namelookup, time_connect); + if (libtest_arg2) { + FILE *moo = fopen(libtest_arg2, "wb"); + if(moo) { + double time_namelookup; + double time_connect; + double time_pretransfer; + double time_starttransfer; + double time_total; + fprintf(moo, "IP: %s\n", ipstr); + curl_easy_getinfo(curl, CURLINFO_NAMELOOKUP_TIME, &time_namelookup); + curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME, &time_connect); + curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME, &time_pretransfer); + curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME, + &time_starttransfer); + curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &time_total); + + /* since the timing will always vary we only compare relative differences + between these 5 times */ + if(time_namelookup > time_connect) { + fprintf(moo, "namelookup vs connect: %f %f\n", + time_namelookup, time_connect); + } + if(time_connect > time_pretransfer) { + fprintf(moo, "connect vs pretransfer: %f %f\n", + time_connect, time_pretransfer); + } + if(time_pretransfer > time_starttransfer) { + fprintf(moo, "pretransfer vs starttransfer: %f %f\n", + time_pretransfer, time_starttransfer); + } + if(time_starttransfer > time_total) { + fprintf(moo, "starttransfer vs total: %f %f\n", + time_starttransfer, time_total); + } + + fclose(moo); } - if(time_connect > time_pretransfer) { - fprintf(moo, "connect vs pretransfer: %f %f\n", - time_connect, time_pretransfer); - } - if(time_pretransfer > time_starttransfer) { - fprintf(moo, "pretransfer vs starttransfer: %f %f\n", - time_pretransfer, time_starttransfer); - } - if(time_starttransfer > time_total) { - fprintf(moo, "starttransfer vs total: %f %f\n", - time_starttransfer, time_total); - } - - fclose(moo); } } |