mirror of https://github.com/moparisthebest/curl
Vincent Bronner made the code use the correct user name + password when
doing proxy authentication.
This commit is contained in:
parent
9e987ac6a2
commit
70f08b5baa
|
@ -221,23 +221,37 @@ CURLcode Curl_output_digest(struct connectdata *conn,
|
||||||
char *cnonce;
|
char *cnonce;
|
||||||
char *tmp = NULL;
|
char *tmp = NULL;
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
|
|
||||||
|
char **allocuserpwd;
|
||||||
|
char *userp;
|
||||||
|
char *passwdp;
|
||||||
struct auth *authp;
|
struct auth *authp;
|
||||||
char **userp;
|
|
||||||
|
|
||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
struct digestdata *d;
|
struct digestdata *d;
|
||||||
|
|
||||||
if(proxy) {
|
if(proxy) {
|
||||||
d = &data->state.proxydigest;
|
d = &data->state.proxydigest;
|
||||||
|
allocuserpwd = &conn->allocptr.proxyuserpwd;
|
||||||
|
userp = conn->proxyuser;
|
||||||
|
passwdp = conn->proxypasswd;
|
||||||
authp = &data->state.authproxy;
|
authp = &data->state.authproxy;
|
||||||
userp = &conn->allocptr.proxyuserpwd;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
d = &data->state.digest;
|
d = &data->state.digest;
|
||||||
|
allocuserpwd = &conn->allocptr.userpwd;
|
||||||
|
userp = conn->user;
|
||||||
|
passwdp = conn->passwd;
|
||||||
authp = &data->state.authhost;
|
authp = &data->state.authhost;
|
||||||
userp = &conn->allocptr.userpwd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* not set means empty */
|
||||||
|
if(!userp)
|
||||||
|
userp=(char *)"";
|
||||||
|
|
||||||
|
if(!passwdp)
|
||||||
|
passwdp=(char *)"";
|
||||||
|
|
||||||
if(!d->nonce) {
|
if(!d->nonce) {
|
||||||
authp->done = FALSE;
|
authp->done = FALSE;
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
|
@ -269,7 +283,7 @@ CURLcode Curl_output_digest(struct connectdata *conn,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
md5this = (unsigned char *)
|
md5this = (unsigned char *)
|
||||||
aprintf("%s:%s:%s", conn->user, d->realm, conn->passwd);
|
aprintf("%s:%s:%s", userp, d->realm, passwdp);
|
||||||
if(!md5this)
|
if(!md5this)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
Curl_md5it(md5buf, md5this);
|
Curl_md5it(md5buf, md5this);
|
||||||
|
@ -347,10 +361,10 @@ CURLcode Curl_output_digest(struct connectdata *conn,
|
||||||
nonce="1053604145", uri="/64", response="c55f7f30d83d774a3d2dcacf725abaca"
|
nonce="1053604145", uri="/64", response="c55f7f30d83d774a3d2dcacf725abaca"
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Curl_safefree(conn->allocptr.userpwd);
|
Curl_safefree(*allocuserpwd);
|
||||||
|
|
||||||
if (d->qop) {
|
if (d->qop) {
|
||||||
*userp =
|
*allocuserpwd =
|
||||||
aprintf( "%sAuthorization: Digest "
|
aprintf( "%sAuthorization: Digest "
|
||||||
"username=\"%s\", "
|
"username=\"%s\", "
|
||||||
"realm=\"%s\", "
|
"realm=\"%s\", "
|
||||||
|
@ -361,7 +375,7 @@ CURLcode Curl_output_digest(struct connectdata *conn,
|
||||||
"qop=\"%s\", "
|
"qop=\"%s\", "
|
||||||
"response=\"%s\"",
|
"response=\"%s\"",
|
||||||
proxy?"Proxy-":"",
|
proxy?"Proxy-":"",
|
||||||
conn->user,
|
userp,
|
||||||
d->realm,
|
d->realm,
|
||||||
d->nonce,
|
d->nonce,
|
||||||
uripath, /* this is the PATH part of the URL */
|
uripath, /* this is the PATH part of the URL */
|
||||||
|
@ -376,7 +390,7 @@ CURLcode Curl_output_digest(struct connectdata *conn,
|
||||||
same nonce in the qop=auth mode. */
|
same nonce in the qop=auth mode. */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
*userp =
|
*allocuserpwd =
|
||||||
aprintf( "%sAuthorization: Digest "
|
aprintf( "%sAuthorization: Digest "
|
||||||
"username=\"%s\", "
|
"username=\"%s\", "
|
||||||
"realm=\"%s\", "
|
"realm=\"%s\", "
|
||||||
|
@ -384,40 +398,40 @@ CURLcode Curl_output_digest(struct connectdata *conn,
|
||||||
"uri=\"%s\", "
|
"uri=\"%s\", "
|
||||||
"response=\"%s\"",
|
"response=\"%s\"",
|
||||||
proxy?"Proxy-":"",
|
proxy?"Proxy-":"",
|
||||||
conn->user,
|
userp,
|
||||||
d->realm,
|
d->realm,
|
||||||
d->nonce,
|
d->nonce,
|
||||||
uripath, /* this is the PATH part of the URL */
|
uripath, /* this is the PATH part of the URL */
|
||||||
request_digest);
|
request_digest);
|
||||||
}
|
}
|
||||||
if(!*userp)
|
if(!*allocuserpwd)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
/* Add optional fields */
|
/* Add optional fields */
|
||||||
if(d->opaque) {
|
if(d->opaque) {
|
||||||
/* append opaque */
|
/* append opaque */
|
||||||
tmp = aprintf("%s, opaque=\"%s\"", *userp, d->opaque);
|
tmp = aprintf("%s, opaque=\"%s\"", *allocuserpwd, d->opaque);
|
||||||
if(!tmp)
|
if(!tmp)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
free(*userp);
|
free(*allocuserpwd);
|
||||||
*userp = tmp;
|
*allocuserpwd = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(d->algorithm) {
|
if(d->algorithm) {
|
||||||
/* append algorithm */
|
/* append algorithm */
|
||||||
tmp = aprintf("%s, algorithm=\"%s\"", *userp, d->algorithm);
|
tmp = aprintf("%s, algorithm=\"%s\"", *allocuserpwd, d->algorithm);
|
||||||
if(!tmp)
|
if(!tmp)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
free(*userp);
|
free(*allocuserpwd);
|
||||||
*userp = tmp;
|
*allocuserpwd = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* append CRLF to the userpwd header */
|
/* append CRLF to the userpwd header */
|
||||||
tmp = (char*) realloc(*userp, strlen(*userp) + 3 + 1);
|
tmp = (char*) realloc(*allocuserpwd, strlen(*allocuserpwd) + 3 + 1);
|
||||||
if(!tmp)
|
if(!tmp)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
strcat(tmp, "\r\n");
|
strcat(tmp, "\r\n");
|
||||||
*userp = tmp;
|
*allocuserpwd = tmp;
|
||||||
|
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue