Skip to content

Segfault when attempting to re-use a curl handle and turning on Proxy NTLM authentication #765

@rcanavan

Description

@rcanavan

In our unittests, there are two tests that abuse a normal HTTP server as a proxy, just to verify that the correct headers are sent. Both use the same "proxy"; the first teset does not use any proxy authentication, the second attempts to use NTLM. As a result, the second test always segfaults at the following location:

 │3395            /* Same for Proxy NTLM authentication */   
 │3396            if(wantProxyNTLMhttp) {     
>│3397              if(!strequal(needle->proxyuser, check->proxyuser) || 
 │3398                 !strequal(needle->proxypasswd, check->proxypasswd))   
 │3399                continue; 
 │3400            }

because in *check, both proxyuser = 0x0 and proxypasswd = 0x0. The following patch would prevent the segfault:

diff --git a/lib/url.c b/lib/url.c
index d165d9c..ea79292 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -3394,7 +3394,8 @@ ConnectionExists(struct SessionHandle *data,

         /* Same for Proxy NTLM authentication */
         if(wantProxyNTLMhttp) {
-          if(!strequal(needle->proxyuser, check->proxyuser) ||
+          if((check->proxyuser == NULL) || (check->proxypasswd == NULL) ||
+             !strequal(needle->proxyuser, check->proxyuser) ||
              !strequal(needle->proxypasswd, check->proxypasswd))
             continue;
         }

curl/libcurl version

curl-7.48.0 and earlier.

operating system

Ubuntu 15.10, OpenSuSE 13.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions