diff options
author | Yang Tse <yangsita@gmail.com> | 2010-11-28 23:11:14 +0100 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2010-11-28 23:11:14 +0100 |
commit | 5db0a412ff6972e51ccddaf1e8d6a27c8de4990f (patch) | |
tree | 8c8cfa609c25c68929554ac1e24eaa4084683152 /tests | |
parent | cbe67a1b71f7098779b8c0cecccb60382cec2d20 (diff) |
atoi: remove atoi usage
Diffstat (limited to 'tests')
-rw-r--r-- | tests/libtest/first.c | 5 | ||||
-rw-r--r-- | tests/libtest/lib521.c | 2 | ||||
-rw-r--r-- | tests/libtest/lib562.c | 2 | ||||
-rw-r--r-- | tests/server/rtspd.c | 4 | ||||
-rw-r--r-- | tests/server/sws.c | 4 |
5 files changed, 10 insertions, 7 deletions
diff --git a/tests/libtest/first.c b/tests/libtest/first.c index 770f9d527..a0e713f48 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -59,7 +59,10 @@ int main(int argc, char **argv) /* this enables the fail-on-alloc-number-N functionality */ env = curl_getenv("CURL_MEMLIMIT"); if(env) { - curl_memlimit(atoi(env)); + char *endptr; + long num = strtol(env, &endptr, 10); + if((endptr != env) && (endptr == env + strlen(env)) && (num > 0)) + curl_memlimit(num); curl_free(env); } #endif diff --git a/tests/libtest/lib521.c b/tests/libtest/lib521.c index a4ae5558a..9e79cb41e 100644 --- a/tests/libtest/lib521.c +++ b/tests/libtest/lib521.c @@ -28,7 +28,7 @@ int test(char *URL) } test_setopt(curl, CURLOPT_URL, URL); - test_setopt(curl, CURLOPT_PORT, atoi(libtest_arg2)); + test_setopt(curl, CURLOPT_PORT, strtol(libtest_arg2, NULL, 10)); test_setopt(curl, CURLOPT_USERPWD, "xxx:yyy"); test_setopt(curl, CURLOPT_VERBOSE, 1L); diff --git a/tests/libtest/lib562.c b/tests/libtest/lib562.c index d78ecce25..acdd79aab 100644 --- a/tests/libtest/lib562.c +++ b/tests/libtest/lib562.c @@ -57,7 +57,7 @@ int test(char *URL) test_setopt(curl, CURLOPT_VERBOSE, 1L); /* set port number */ - test_setopt(curl, CURLOPT_PORT, atoi(libtest_arg2) ); + test_setopt(curl, CURLOPT_PORT, strtol(libtest_arg2, NULL, 10)); /* specify target */ test_setopt(curl,CURLOPT_URL, URL); diff --git a/tests/server/rtspd.c b/tests/server/rtspd.c index d2471b998..f751f1153 100644 --- a/tests/server/rtspd.c +++ b/tests/server/rtspd.c @@ -531,8 +531,8 @@ static int ProcessRequest(struct httprequest *req) /* if the host name starts with test, the port number used in the CONNECT line will be used as test number! */ char *portp = strchr(doc, ':'); - if(portp) - req->testno = atoi(portp+1); + if(portp && (*(portp+1) != '\0') && ISDIGIT(*(portp+1))) + req->testno = strtol(portp+1, NULL, 10); else req->testno = DOCNUMBER_CONNECT; } diff --git a/tests/server/sws.c b/tests/server/sws.c index 1650226e6..65a61c2ce 100644 --- a/tests/server/sws.c +++ b/tests/server/sws.c @@ -467,8 +467,8 @@ static int ProcessRequest(struct httprequest *req) /* if the host name starts with test, the port number used in the CONNECT line will be used as test number! */ char *portp = strchr(doc, ':'); - if(portp) - req->testno = atoi(portp+1); + if(portp && (*(portp+1) != '\0') && ISDIGIT(*(portp+1))) + req->testno = strtol(portp+1, NULL, 10); else req->testno = DOCNUMBER_CONNECT; } |