Skip to content

Commit 7aaf9a3

Browse files
committed
http: replace atoi use in Curl_http_follow with curlx_str_number
In an attempt to weed out atoi() use all over. Closes curl#19478
1 parent 3b4bf3f commit 7aaf9a3

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

lib/http.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,21 +1302,25 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl,
13021302
/* Clear auth if this redirects to a different port number or protocol,
13031303
unless permitted */
13041304
if(!data->set.allow_auth_to_other_hosts && (type != FOLLOW_FAKE)) {
1305-
char *portnum;
13061305
int port;
13071306
bool clear = FALSE;
13081307

13091308
if(data->set.use_port && data->state.allow_port)
13101309
/* a custom port is used */
13111310
port = (int)data->set.use_port;
13121311
else {
1312+
curl_off_t value;
1313+
char *portnum;
1314+
const char *p;
13131315
uc = curl_url_get(data->state.uh, CURLUPART_PORT, &portnum,
13141316
CURLU_DEFAULT_PORT);
13151317
if(uc) {
13161318
free(follow_url);
13171319
return Curl_uc_to_curlcode(uc);
13181320
}
1319-
port = atoi(portnum);
1321+
p = portnum;
1322+
curlx_str_number(&p, &value, 0xffff);
1323+
port = (int)value;
13201324
free(portnum);
13211325
}
13221326
if(port != data->info.conn_remote_port) {

0 commit comments

Comments
 (0)