diff --git a/ares_init.c b/ares_init.c index 442f8f54..eb1719ab 100644 --- a/ares_init.c +++ b/ares_init.c @@ -129,8 +129,12 @@ int ares_init_options(ares_channel *channelptr, struct ares_options *options, if (env) curl_memdebug(env); env = getenv("CARES_MEMLIMIT"); - if (env) - curl_memlimit(atoi(env)); + if (env) { + char *endptr; + long num = strtol(env, &endptr, 10); + if((endptr != env) && (endptr == env + strlen(env)) && (num > 0)) + curl_memlimit(num); + } #endif if (ares_library_initialized() != ARES_SUCCESS) @@ -1396,13 +1400,13 @@ static int set_options(ares_channel channel, const char *str) q++; val = try_option(p, q, "ndots:"); if (val && channel->ndots == -1) - channel->ndots = atoi(val); + channel->ndots = (int)strtol(val, NULL, 10); val = try_option(p, q, "retrans:"); if (val && channel->timeout == -1) - channel->timeout = atoi(val); + channel->timeout = (int)strtol(val, NULL, 10); val = try_option(p, q, "retry:"); if (val && channel->tries == -1) - channel->tries = atoi(val); + channel->tries = (int)strtol(val, NULL, 10); val = try_option(p, q, "rotate"); if (val && channel->rotate == -1) channel->rotate = 1; diff --git a/ares_options.c b/ares_options.c index 7b957a55..70280526 100644 --- a/ares_options.c +++ b/ares_options.c @@ -139,7 +139,7 @@ int ares_set_servers_csv(ares_channel channel, char* csv = NULL; char* ptr; char* start_host; - int port; + long port; bool found_port; int rv = ARES_SUCCESS; struct ares_addr_node *servers = NULL; @@ -188,7 +188,7 @@ int ares_set_servers_csv(ares_channel channel, if ((pp != start_host) && ((pp + 1) < ptr)) { /* Found it. */ found_port = true; - port = atoi(pp + 1); + port = strtol(pp + 1, NULL, 10); *pp = 0; /* null terminate host */ } /* resolve host, try ipv4 first, rslt is in network byte order */