cURL / Mailing Lists / curl-library / Single Mail

curl-library

Repost of bug 440 patch

From: Arunav Sanyal <arunav.sanyal91_at_gmail.com>
Date: Thu, 18 Apr 2013 17:11:39 +0530

The thread died after i posted this patch so I am resubmitting this again

Ok I expected my patch to have side effects on other auth schemes. I had no
way to test them(my org does not support any other auth mechanism) and thus
couldnt test them all before sending. Right now I am sending one more edit
which should solve the problem. However, I am shooting in the dark and it
would be nice if other people suggested changes as well

Command diff -u http.c http_new.c > diff2.txt(ubuntu 12.10)

Curl version - 7.29.0

Contents of diff2.txt:-

--- http.c 2013-03-31 11:09:04.706526529 +0530
+++ http_new.c 2013-03-31 11:14:24.744113499 +0530
@@ -236,6 +236,15 @@
   const char *pwd;
   CURLcode error;

+
+ if(!conn->bits.user_passwd && !proxy){
+ return CURLE_LOGIN_DENIED; //actually some other error
like userpwd not supplied would be much better
+ }
+
+ if(!conn->bits.proxy_user_passwd && proxy){
+ return CURLE_LOGIN_DENIED;
+ }
+
   if(proxy) {
     userp = &conn->allocptr.proxyuserpwd;
     user = conn->proxyuser;
@@ -439,15 +448,13 @@
   if(data->state.authproblem)
     return
data->set.http_fail_on_error?CURLE_HTTP_RETURNED_ERROR:CURLE_OK;

- if(conn->bits.user_passwd &&
- ((data->req.httpcode == 401) ||
+ if(((data->req.httpcode == 401) ||
       (conn->bits.authneg && data->req.httpcode < 300))) {
     pickhost = pickoneauth(&data->state.authhost);
     if(!pickhost)
       data->state.authproblem = TRUE;
   }
- if(conn->bits.proxy_user_passwd &&
- ((data->req.httpcode == 407) ||
+ if(((data->req.httpcode == 407) ||
       (conn->bits.authneg && data->req.httpcode < 300))) {
     pickproxy = pickoneauth(&data->state.authproxy);
     if(!pickproxy)
@@ -566,10 +573,8 @@
 #endif
   if(authstatus->picked == CURLAUTH_BASIC) {
     /* Basic */
- if((proxy && conn->bits.proxy_user_passwd &&
- !Curl_checkheaders(data, "Proxy-authorization:")) ||
- (!proxy && conn->bits.user_passwd &&
- !Curl_checkheaders(data, "Authorization:"))) {
+ if((proxy&&!Curl_checkheaders(data, "Proxy-authorization:")) ||
+ (!proxy&&!Curl_checkheaders(data, "Authorization:"))) {
       auth="Basic";
       result = http_output_basic(conn, proxy);
       if(result)
@@ -624,15 +629,6 @@
   authhost = &data->state.authhost;
   authproxy = &data->state.authproxy;

- if((conn->bits.httpproxy && conn->bits.proxy_user_passwd) ||
- conn->bits.user_passwd)
- /* continue please */ ;
- else {
- authhost->done = TRUE;
- authproxy->done = TRUE;
- return CURLE_OK; /* no authentication with no user or password */
- }
-
   if(authhost->want && !authhost->picked)
     /* The app has selected one or more methods, but none has been picked
        so far by a server round-trip. Then we set the picked one to the

This is not tested.

-- 
Arunav Sanyal
4th year undergraduate student
B.E (Hons) Computer Science
BITS Pilani K.K Birla Goa Campus

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-04-18