mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
moved the proxyuser and proxypasswd fields from the sessionhandle to the
connectdata to work as expected
This commit is contained in:
parent
1a192c489b
commit
071c95128e
@ -732,7 +732,7 @@ CURLcode Curl_http(struct connectdata *conn)
|
||||
#endif
|
||||
#ifdef USE_SSLEAY
|
||||
if(data->state.authwant == CURLAUTH_NTLM) {
|
||||
result = Curl_output_ntlm(conn);
|
||||
result = Curl_output_ntlm(conn, FALSE);
|
||||
if(result)
|
||||
return result;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ typedef enum {
|
||||
CURLntlm Curl_input_ntlm(struct connectdata *conn, char *header);
|
||||
|
||||
/* this is for creating ntlm header output */
|
||||
CURLcode Curl_output_ntlm(struct connectdata *conn);
|
||||
CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy);
|
||||
|
||||
void Curl_ntlm_cleanup(struct SessionHandle *data);
|
||||
|
||||
|
113
lib/url.c
113
lib/url.c
@ -167,6 +167,11 @@ RETSIGTYPE alarmfunc(int signal)
|
||||
}
|
||||
#endif
|
||||
|
||||
void Curl_safefree(void *ptr)
|
||||
{
|
||||
if(ptr)
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
/*
|
||||
* This is the internal function curl_easy_cleanup() calls. This should
|
||||
@ -194,11 +199,8 @@ CURLcode Curl_close(struct SessionHandle *data)
|
||||
if(data->change.cookielist) /* clean up list if any */
|
||||
curl_slist_free_all(data->change.cookielist);
|
||||
|
||||
if(data->state.auth_host)
|
||||
free(data->state.auth_host);
|
||||
|
||||
if(data->state.scratch)
|
||||
free(data->state.scratch);
|
||||
Curl_safefree(data->state.auth_host);
|
||||
Curl_safefree(data->state.scratch);
|
||||
|
||||
if(data->change.proxy_alloc)
|
||||
free(data->change.proxy);
|
||||
@ -209,8 +211,7 @@ CURLcode Curl_close(struct SessionHandle *data)
|
||||
if(data->change.url_alloc)
|
||||
free(data->change.url);
|
||||
|
||||
if(data->state.headerbuff)
|
||||
free(data->state.headerbuff);
|
||||
Curl_safefree(data->state.headerbuff);
|
||||
|
||||
#ifndef CURL_DISABLE_HTTP
|
||||
if(data->set.cookiejar) {
|
||||
@ -225,8 +226,7 @@ CURLcode Curl_close(struct SessionHandle *data)
|
||||
/* free the connection cache */
|
||||
free(data->state.connects);
|
||||
|
||||
if(data->info.contenttype)
|
||||
free(data->info.contenttype);
|
||||
Curl_safefree(data->info.contenttype);
|
||||
|
||||
Curl_digest_cleanup(data);
|
||||
|
||||
@ -1233,14 +1233,9 @@ CURLcode Curl_disconnect(struct connectdata *conn)
|
||||
/* This is set if protocol-specific cleanups should be made */
|
||||
conn->curl_disconnect(conn);
|
||||
|
||||
if(conn->proto.generic)
|
||||
free(conn->proto.generic);
|
||||
|
||||
if(conn->newurl)
|
||||
free(conn->newurl);
|
||||
|
||||
if(conn->path) /* the URL path part */
|
||||
free(conn->path);
|
||||
Curl_safefree(conn->proto.generic);
|
||||
Curl_safefree(conn->newurl);
|
||||
Curl_safefree(conn->path); /* the URL path part */
|
||||
|
||||
#ifdef USE_SSLEAY
|
||||
Curl_SSL_Close(conn);
|
||||
@ -1252,32 +1247,20 @@ CURLcode Curl_disconnect(struct connectdata *conn)
|
||||
if(-1 != conn->firstsocket)
|
||||
sclose(conn->firstsocket);
|
||||
|
||||
if(conn->user)
|
||||
free(conn->user);
|
||||
if(conn->passwd)
|
||||
free(conn->passwd);
|
||||
|
||||
if(conn->allocptr.proxyuserpwd)
|
||||
free(conn->allocptr.proxyuserpwd);
|
||||
if(conn->allocptr.uagent)
|
||||
free(conn->allocptr.uagent);
|
||||
if(conn->allocptr.userpwd)
|
||||
free(conn->allocptr.userpwd);
|
||||
if(conn->allocptr.accept_encoding)
|
||||
free(conn->allocptr.accept_encoding);
|
||||
if(conn->allocptr.rangeline)
|
||||
free(conn->allocptr.rangeline);
|
||||
if(conn->allocptr.ref)
|
||||
free(conn->allocptr.ref);
|
||||
if(conn->allocptr.cookie)
|
||||
free(conn->allocptr.cookie);
|
||||
if(conn->allocptr.host)
|
||||
free(conn->allocptr.host);
|
||||
if(conn->allocptr.cookiehost)
|
||||
free(conn->allocptr.cookiehost);
|
||||
|
||||
if(conn->proxyhost)
|
||||
free(conn->proxyhost);
|
||||
Curl_safefree(conn->user);
|
||||
Curl_safefree(conn->passwd);
|
||||
Curl_safefree(conn->proxyuser);
|
||||
Curl_safefree(conn->proxypasswd);
|
||||
Curl_safefree(conn->allocptr.proxyuserpwd);
|
||||
Curl_safefree(conn->allocptr.uagent);
|
||||
Curl_safefree(conn->allocptr.userpwd);
|
||||
Curl_safefree(conn->allocptr.accept_encoding);
|
||||
Curl_safefree(conn->allocptr.rangeline);
|
||||
Curl_safefree(conn->allocptr.ref);
|
||||
Curl_safefree(conn->allocptr.cookie);
|
||||
Curl_safefree(conn->allocptr.host);
|
||||
Curl_safefree(conn->allocptr.cookiehost);
|
||||
Curl_safefree(conn->proxyhost);
|
||||
|
||||
Curl_free_ssl_config(&conn->ssl_config);
|
||||
|
||||
@ -1722,8 +1705,8 @@ static CURLcode ConnectPlease(struct connectdata *conn,
|
||||
#endif
|
||||
|
||||
if (conn->data->set.proxytype == CURLPROXY_SOCKS5) {
|
||||
return handleSock5Proxy(conn->data->state.proxyuser,
|
||||
conn->data->state.proxypasswd,
|
||||
return handleSock5Proxy(conn->proxyuser,
|
||||
conn->proxypasswd,
|
||||
conn,
|
||||
conn->firstsocket) ?
|
||||
CURLE_COULDNT_CONNECT : CURLE_OK;
|
||||
@ -2065,29 +2048,36 @@ static CURLcode CreateConnection(struct SessionHandle *data,
|
||||
* Take care of proxy authentication stuff
|
||||
*************************************************************/
|
||||
if(conn->bits.proxy_user_passwd) {
|
||||
data->state.proxyuser[0] =0;
|
||||
data->state.proxypasswd[0]=0;
|
||||
char proxyuser[MAX_CURL_USER_LENGTH]="";
|
||||
char proxypasswd[MAX_CURL_PASSWORD_LENGTH]="";
|
||||
|
||||
if(*data->set.proxyuserpwd != ':') {
|
||||
/* the name is given, get user+password */
|
||||
sscanf(data->set.proxyuserpwd, "%127[^:]:%127[^\n]",
|
||||
data->state.proxyuser, data->state.proxypasswd);
|
||||
proxyuser, proxypasswd);
|
||||
}
|
||||
else
|
||||
/* no name given, get the password only */
|
||||
sscanf(data->set.proxyuserpwd+1, "%127[^\n]", data->state.proxypasswd);
|
||||
sscanf(data->set.proxyuserpwd+1, "%127[^\n]", proxypasswd);
|
||||
|
||||
/* check for password, if no ask for one */
|
||||
if( !data->state.proxypasswd[0] ) {
|
||||
if( !proxypasswd[0] ) {
|
||||
if(data->set.fpasswd( data->set.passwd_client,
|
||||
"proxy password:",
|
||||
data->state.proxypasswd,
|
||||
sizeof(data->state.proxypasswd))) {
|
||||
proxypasswd,
|
||||
sizeof(proxypasswd))) {
|
||||
failf(data, "Bad password from password callback");
|
||||
return CURLE_BAD_PASSWORD_ENTERED;
|
||||
}
|
||||
}
|
||||
|
||||
conn->proxyuser = strdup(proxyuser);
|
||||
if(!conn->proxyuser)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
conn->proxypasswd = strdup(proxypasswd);
|
||||
if(!conn->proxypasswd)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
/*************************************************************
|
||||
@ -2097,7 +2087,6 @@ static CURLcode CreateConnection(struct SessionHandle *data,
|
||||
conn->ppath = conn->path;
|
||||
conn->hostname = conn->name;
|
||||
|
||||
|
||||
/*************************************************************
|
||||
* Detect what (if any) proxy to use
|
||||
*************************************************************/
|
||||
@ -2215,8 +2204,20 @@ static CURLcode CreateConnection(struct SessionHandle *data,
|
||||
"%" MAX_CURL_PASSWORD_LENGTH_TXT "[^@]",
|
||||
user, passwd))) {
|
||||
/* found user and password, rip them out */
|
||||
strcpy(data->state.proxyuser, user);
|
||||
strcpy(data->state.proxypasswd, passwd);
|
||||
if(conn->proxyuser)
|
||||
free(conn->proxyuser);
|
||||
conn->proxyuser = strdup(user);
|
||||
|
||||
if(!conn->proxyuser)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
if(conn->proxypasswd)
|
||||
free(conn->proxypasswd);
|
||||
conn->proxypasswd = strdup(passwd);
|
||||
|
||||
if(!conn->proxypasswd)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
conn->bits.proxy_user_passwd = TRUE; /* enable it */
|
||||
|
||||
ptr = strdup(ptr+1);
|
||||
@ -2976,7 +2977,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
|
||||
if(conn->bits.proxy_user_passwd) {
|
||||
char *authorization;
|
||||
snprintf(data->state.buffer, BUFSIZE, "%s:%s",
|
||||
data->state.proxyuser, data->state.proxypasswd);
|
||||
conn->proxyuser, conn->proxypasswd);
|
||||
if(Curl_base64_encode(data->state.buffer, strlen(data->state.buffer),
|
||||
&authorization) >= 0) {
|
||||
if(conn->allocptr.proxyuserpwd)
|
||||
|
@ -42,4 +42,5 @@ bool Curl_ssl_config_matches(struct ssl_config_data* data,
|
||||
bool Curl_clone_ssl_config(struct ssl_config_data* source,
|
||||
struct ssl_config_data* dest);
|
||||
void Curl_free_ssl_config(struct ssl_config_data* sslc);
|
||||
void Curl_safefree(void *ptr);
|
||||
#endif
|
||||
|
@ -416,6 +416,9 @@ struct connectdata {
|
||||
char *user; /* user name string, allocated */
|
||||
char *passwd; /* password string, allocated */
|
||||
|
||||
char *proxyuser; /* proxy user name string, allocated */
|
||||
char *proxypasswd; /* proxy password string, allocated */
|
||||
|
||||
struct timeval now; /* "current" time */
|
||||
struct timeval created; /* creation time */
|
||||
int firstsocket; /* the main socket to use */
|
||||
@ -618,8 +621,6 @@ struct UrlState {
|
||||
} used_interface;
|
||||
|
||||
/* buffers to store authentication data in, as parsed from input options */
|
||||
char proxyuser[MAX_CURL_USER_LENGTH];
|
||||
char proxypasswd[MAX_CURL_PASSWORD_LENGTH];
|
||||
struct timeval keeps_speed; /* for the progress meter really */
|
||||
|
||||
/* 'connects' will be an allocated array with pointers. If the pointer is
|
||||
|
Loading…
Reference in New Issue
Block a user