Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--max-redirs -1 leads to error "bad argument" #2038

Closed
cbartl opened this issue Oct 31, 2017 · 1 comment
Closed

--max-redirs -1 leads to error "bad argument" #2038

cbartl opened this issue Oct 31, 2017 · 1 comment
Assignees

Comments

@cbartl
Copy link

cbartl commented Oct 31, 2017

I did this

curl --max-redirs -1 http://dummy.restapiexample.com/api/v1/employees

I expected the following

Get a JSON with HTTP status 200

instead got the following

curl: (43) A libcurl function was given a bad argument

curl/libcurl version

curl 7.56.1 (x86_64-suse-linux-gnu) libcurl/7.56.1 OpenSSL/1.0.2l zlib/1.2.11 libidn2/2.0.4 libpsl/0.18.0 (+libidn2/2.0.4) libssh2/1.8.0 nghttp2/1.27.0
Release-Date: 2017-10-23
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy Metalink PSL 

operating system

openSUSE Tumbleweed

Notes

Use --max-redirs 9999 instead of -1 as workaround.

Did a little research and found commit f121575 to be a candidate for cause.

  case CURLOPT_MAXREDIRS:
    /*
     * The maximum amount of hops you allow curl to follow Location:
     * headers. This should mostly be used to detect never-ending loops.
     */
    arg = va_arg(param, long);
    if(arg < 0)
      return CURLE_BAD_FUNCTION_ARGUMENT;
    data->set.maxredirs = arg;
    break;
@bagder
Copy link
Member

bagder commented Oct 31, 2017

Confirmed. Patch coming...

bagder added a commit that referenced this issue Oct 31, 2017
... which is valid according to documentation. Regression since
f121575.

Reported-by: cbartl on github
Fixes #2038
bagder added a commit that referenced this issue Nov 1, 2017
... which is valid according to documentation. Regression since
f121575.

Verified now in test 501.

Reported-by: cbartl on github
Fixes #2038
@bagder bagder closed this as completed in 25cb41d Nov 1, 2017
@lock lock bot locked as resolved and limited conversation to collaborators May 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants