Skip to content

CURLOPT_FOLLOWLOCATION with CURLOPT_CURLU: infinitely following locations #5709

@ghost

Description

I did this

#include <curl/curl.h>

int main(){
    CURLU* url = curl_url();
    curl_url_set(url, CURLUPART_URL, "https://google.com", 0);

    CURL* get = curl_easy_init();

    curl_easy_setopt(get, CURLOPT_CURLU, url);
    curl_easy_setopt(get, CURLOPT_FOLLOWLOCATION, 1L);
    curl_easy_setopt(get, CURLOPT_VERBOSE, 1L);
    curl_easy_perform(get);

    curl_easy_cleanup(get);
    curl_url_cleanup(url);
}

I expected the following

I expected this would follow to the desired location. Instead curl_easy_perform() is blocking forever, infinitely following the location. Just happens when I set the url with CURLOPT_CURLU, CURLOPT_URL is working as expected. Same error for multiple hosts.

curl/libcurl version

curl 7.71.1 (x86_64-pc-linux-gnu) libcurl/7.71.1 OpenSSL/1.1.1g zlib/1.2.11 libidn2/2.3.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh2/1.9.0 nghttp2/1.41.0
Release-Date: 2020-07-01
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS GSS-API HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL TLS-SRP UnixSockets

operating system

Linux 5.7.8-arch1-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