2687 Commits

Author SHA1 Message Date
Jay Satiro
6f93d5f604
lib: fix conversion warnings with gcc on macOS 2023-05-21 14:02:31 +02:00
Emanuele Torre
f198d33e8d
checksrc: disallow spaces before labels
Out of 415 labels throughout the code base, 86 of those labels were
not at the start of the line. Which means labels always at the start of
the line is the favoured style overall with 329 instances.

Out of the 86 labels not at the start of the line:
* 75 were indented with the same indentation level of the following line
* 8 were indented with exactly one space
* 2 were indented with one fewer indentation level then the following
  line
* 1 was indented with the indentation level of the following line minus
  three space (probably unintentional)

Co-Authored-By: Viktor Szakats

Closes #11134
2023-05-18 20:45:04 +02:00
Daniel Stenberg
39a33fcac0
tool_operate: refuse (--data or --form) and --continue-at combo
libcurl assumes that a --continue-at resumption is done to continue an
upload using the read callback and neither --data nor --form use
that and thus won't do what the user wants. Whatever the user wants
with this strange combination.

Add test 426 to verify.

Reported-by: Smackd0wn on github
Fixes #11081
Closes #11083
2023-05-08 14:10:44 +02:00
Jay Satiro
30ba26d9c3 tool_cb_hdr: Fix 'Location:' formatting for early VTE terminals
- Disable hyperlink formatting for the 'Location:' header value in VTE
  0.48.1 and earlier, since it is buggy in some of those versions.

Prior to this change those terminals may show the location header value
as gibberish or show it twice.

Ref: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda#backward-compatibility

Fixes https://github.com/curl/curl/issues/10428
Closes https://github.com/curl/curl/pull/11071
2023-05-05 02:52:23 -04:00
Daniel Stenberg
9ce7eee070
checksrc: find bad indentation in conditions without open brace
If the previous line starts with if/while/for AND ends with a closed
parenthesis and there's an equal number of open and closed parentheses
on that line, verify that this line is indented $indent more steps, if
not a cpp line.

Also adjust the fall-out from this fix.

Closes #11054
2023-04-28 23:11:00 +02:00
Emanuele Torre
7f712399d5
checksrc: check for spaces before the colon of switch labels
Closes #11047
2023-04-27 23:26:50 +02:00
Daniel Stenberg
d567cca1de
checksrc: fix SPACEBEFOREPAREN for conditions starting with "*"
The open paren check wants to warn for spaces before open parenthesis
for if/while/for but also for any function call. In order to avoid
catching function pointer declarations, the logic allows a space if the
first character after the open parenthesis is an asterisk.

I also spotted what we did not include "switch" in the check but we should.

This check is a little lame, but we reduce this problem by not allowing
that space for if/while/for/switch.

Reported-by: Emanuele Torre
Closes #11044
2023-04-27 17:24:47 +02:00
Daniel Stenberg
8ff820388f
src/tool_operhlp.c: fix value stored to 'uerr' is never read
Ref: https://github.com/curl/curl/pull/10974#issuecomment-1510461343
Reported-by: Viktor Szakats
Closes #10982
2023-04-17 09:07:07 +02:00
Daniel Stenberg
54ac447b11
curl: do NOT append file name to path for upload when there's a query
Added test 425 to verify.

Reported-by: Dirk Rosenkranz
Bug: https://curl.se/mail/archive-2023-04/0008.html
Closes #10969
2023-04-15 10:52:33 +02:00
Daniel Stenberg
e39754f6a2
curl: add --proxy-http2
For trying HTTP/2 with an HTTPS proxy.

Closes #10926
2023-04-14 10:39:23 +02:00
Daniel Stenberg
808cb31756
tool_writeout: add URL component variables
Output specific components from the used URL. The following variables
are added for this purpose:

  url.scheme, url.user, url.password, url.options, url.host, url.port,
  url.path, url.query, url.fragment, url.zoneid

Add the following for outputting parts of the "effective URL":

 urle.scheme, urle.user, urle.password, urle.options, urle.host, urle.port,
 urle.path, urle.query, urle.fragment, urle.zoneid

Added test 423 and 424 to verify.

Closes #10853
2023-04-04 14:42:44 +02:00
Daniel Stenberg
c0a9f905e6
tool_operate: pass a long as CURLOPT_HEADEROPT argument
Closes #10798
2023-03-22 13:51:37 +01:00
Daniel Stenberg
e2452cf60e
tool_getparam: error if --next is used without a prior URL
Reported-by: 積丹尼 Dan Jacobson
Ref: https://github.com/curl/curl/pull/10769#discussion_r1137895629

Closes #10782
2023-03-17 14:07:10 +01:00
Marcel Raad
ff5c3455ce
tool_operate: silence unused parameter warning
`global` is only used in the `my_setopt` macro version without
`CURL_DISABLE_LIBCURL_OPTION` since commit 4774decf10a.

Closes https://github.com/curl/curl/pull/10752
2023-03-13 13:43:26 +01:00
Jay Satiro
2f17a9b654 tool: improve --stderr handling
- freopen stderr with the user-specified file (--stderr file) instead of
  using a separate 'errors' stream.

- In tool_setup.h override stdio.h's stderr macro as global variable
  tool_stderr.

Both freopen and overriding the stderr macro are necessary because if
the user-specified filename is "-" then stdout is assigned to
tool_stderr and no freopen takes place. See the PR for more information.

Ref: https://github.com/curl/curl/issues/10491

Closes https://github.com/curl/curl/pull/10673
2023-03-12 00:58:40 -05:00
Viktor Szakats
079079b2fd
src: silence wmain() warning for all build methods
llvm/clang and gcc doesn't recognize the wmain() function in Unicode
Windows builds:

llvm/clang:
```
../../src/tool_main.c:239:5: warning: no previous prototype for function 'wmain' [-Wmissing-prototypes]
int wmain(int argc, wchar_t *argv[])
    ^
1 warning generated.
```

gcc:
```
../../src/tool_main.c:239:5: warning: no previous prototype for 'wmain' [-Wmissing-prototypes]
  239 | int wmain(int argc, wchar_t *argv[])
      |     ^~~~~
```

Before this patch, we already silenced it with CMake. This patch moves
the silencing to the source, so that it applies to all build tools.

Bug: https://github.com/curl/curl/issues/7229#issuecomment-1464806651

Reviewed-by: Marcel Raad
Closes #10744
2023-03-11 15:21:43 +00:00
Daniel Stenberg
842be672c8
tool_writeout_json. fix the output for duplicate header names
Header entries with index != 0 are handled at the index 0 level so they
should then be skipped when iterated over.

Reported-by: Boris Okunskiy
Fixes #10704
Closes #10707
2023-03-09 00:13:41 +01:00
Grisha Levit
1dd929674e
tool: dump headers even if file is write-only
The fixes in #10079 brought a (seemingly unrelated) change of open mode
from `wb`/`ab` to `wb+`/`ab+` for the headerfile. This makes it no
longer possible to write the header file to e.g. a pipe, like:

    curl -D >(grep ...) file:///dev/null

Which presently results in `Warning: Failed to open /dev/fd/63`

See #10079
Closes #10675
2023-03-06 11:14:37 +01:00
Daniel Stenberg
835682661c
misc: remove support for curl_off_t < 8 bytes
Closes #10597
2023-02-24 17:05:33 +01:00
Jay Satiro
d9b7f6e750
curl: make -w's %{stderr} use the file set with --stderr
Reported-by: u20221022 on github
Fixes #10491
Closes #10569
2023-02-23 10:05:13 +01:00
Daniel Stenberg
60e13311f4
tool_operate: propagate error codes for missing URL after --next
Fixes #10558
Reported-by: u20221022 on github
Closes #10580
2023-02-22 08:44:45 +01:00
Daniel Stenberg
780ff2c95c
tool_getparam: don't add a new node for just --no-remote-name
Unless --remote-name-all is used.

Fixes #10564
Reported-by: u20221022 on github
Closes #10582
2023-02-22 08:43:13 +01:00
Daniel Stenberg
475207c1c8
tool_progress: shut off progress meter for --silent in parallel
Reported-by: finkjsc on github
Fixes #10573
Closes #10579
2023-02-21 16:11:20 +01:00
Daniel Stenberg
1c9cfb7af3
tool_operate: avoid fclose(NULL) on bad header dump file
Fixes #10570
Reported-by: Jérémy Rabasco
Closes #10571
2023-02-21 10:34:29 +01:00
Jay Satiro
41dfb7f516 tool_operate: fix scanbuild compiler warning
Prior to this change Azure CI scanbuild warned of a potential NULL
pointer string passed to strtol when CURLDEBUG enabled, even though the
way the code was written it wouldn't have happened.

Bug: https://github.com/curl/curl/commit/5479d991#r101159711
Reported-by: Marcel Raad

Closes https://github.com/curl/curl/pull/10559
2023-02-18 19:02:40 -05:00
Daniel Stenberg
6841f2ed5f
curl: make --silent work stand-alone
- renamed the struct field to 'silent' to match the cmdline option
- make --show-error toggle independently of --silent
- make --silent independent of ->noprogress as well

By doing this, the three options --silent, --no-progress-meter and
--show-error should work independently of each other and also work with
and without '--no-' prefix as documented.

Reported-by: u20221022 on github
Fixes #10535
Closes #10536
2023-02-17 09:22:49 +01:00
Daniel Stenberg
5479d9916e
tool_operate: allow debug builds to set buffersize
Using the CURL_BUFFERSIZE environment variable.

Closes #10532
2023-02-16 14:36:24 +01:00
Daniel Stenberg
ce24ea373f
tool_getparam: make --get a true boolean
To match how it is documented in the man page.

Fixes #10527
Reported-by: u20221022 on github
Closes #10531
2023-02-16 10:53:59 +01:00
Daniel Stenberg
95fe2bba74
tool_operate: move the 'updated' variable
This was already done by Dan Fandrich in the previous PR but somehow I
lost that fixup.

Follow-up to 349c5391f2121e
2023-02-07 12:16:13 +01:00
Dan Fandrich
df3722a46c
tool_operate: Fix error codes during DOS filename sanitize
It would return CURLE_URL_MALFORMAT in an OOM condition.

Closes #10414
2023-02-07 08:20:19 +01:00
Dan Fandrich
349c5391f2
tool_operate: Fix error codes on bad URL & OOM
curl would erroneously report CURLE_OUT_OF_MEMORY in some cases instead
of CURLE_URL_MALFORMAT. In other cases, it would erroneously return
CURLE_URL_MALFORMAT instead of CURLE_OUT_OF_MEMORY.  Add a test case to
test the former condition.

Fixes #10130
Closes #10414
2023-02-07 08:20:04 +01:00
Daniel Stenberg
e7512e78c2
tool_operate: repair --rate
Regression from a55256cfb242 (7.87.0)
Reported-by: highmtworks on github
Fixes #10357
Closes #10358
2023-01-29 16:06:06 +01:00
Daniel Stenberg
e6b72644c2
tool_getparam: fix compiler warning when !HAVE_WRITABLE_ARGV
Follow-up to 2ed0e1f70ee176edf3d2

Closes #10286
2023-01-13 10:39:23 +01:00
Daniel Stenberg
7d3b167f48
curl: output warning at --verbose output for debug-enabled version
+ a libcurl warning in the debug output

Assisted-by: Jay Satiro

Ref: https://curl.se/mail/lib-2023-01/0039.html
Closes #10278
2023-01-12 17:59:26 +01:00
Daniel Stenberg
13991d60ee
src: add --http3-only
Warning: --http3 and --http3-only are subject to change again (or be
removed) before HTTP/3 support goes non-experimental.

Closes #10264
2023-01-12 16:18:05 +01:00
Harry Sintonen
2ed0e1f70e
tool_getparam: fix hiding of command line secrets
Closes #10276
2023-01-12 14:09:23 +01:00
Stefan Eissing
24e4e57cf3
tool_operate: fix headerfile writing
Do not rely on the first transfer started to be the first to get a
response (remember -Z). All transfers now write the headefile (-D) in
append mode, making sure that the order of transfer responses does not
lead to overwrites of previous data.

Closes #10224
2023-01-04 23:11:54 +01:00
Daniel Stenberg
2bc1d775f5
copyright: update all copyright lines and remove year ranges
- they are mostly pointless in all major jurisdictions
- many big corporations and projects already don't use them
- saves us from pointless churn
- git keeps history for us
- the year range is kept in COPYING

checksrc is updated to allow non-year using copyright statements

Closes #10205
2023-01-03 09:19:21 +01:00
Daniel Stenberg
c6aa19c1da
writeout: add %{certs} and %{num_certs}
Let users get the server certificate chain using the command line

Closes #10019
2022-12-27 22:41:17 +01:00
Daniel Stenberg
0bf8b796a0
tool_operate: share HSTS between handles 2022-12-27 15:22:01 +01:00
John Bampton
80efd3bc61
misc: fix grammar and spelling
Closes #10137
2022-12-22 18:07:07 +01:00
Marcel Raad
03ac7ab4ad
tool_operate: fix CURLOPT_SOCKS5_GSSAPI_NEC type
`CURLOPT_SOCKS5_GSSAPI_NEC` is a long, while `socks5_gssapi_nec` was
made a bool in commit 4ac64eadf60.

Closes https://github.com/curl/curl/pull/10124
2022-12-21 15:37:54 +01:00
Daniel Stenberg
614f78131a
tool_paramhlp: free the proto strings on exit
And also make sure that repeated use of the options free the previous
string before it stores a new.

Follow-up from e6f8445edef8e7996d

Closes #10098
2022-12-15 08:28:38 +01:00
Daniel Stenberg
24d494c264
tool_cfgable: free the ssl_ec_curves on exit
Follow-up to ede125b7b

Closes #10097
2022-12-15 08:26:04 +01:00
Emil Engler
8b1e5df73d
tool: determine the correct fopen option for -D
This commit fixes a bug in the dump-header feature regarding the
determination of the second fopen(3) option.

Reported-by: u20221022 on github

See #4753
See #4762
Fixes #10074
Closes #10079
2022-12-12 09:04:51 +01:00
Boris Verkhovskiy
4ac64eadf6
tool_cfgable: make socks5_gssapi_nec a boolean
Closes #10078
2022-12-11 12:34:19 +01:00
Daniel Gustafsson
76b73c7468 tool_formparse: avoid clobbering on function params
While perfectly legal to do, clobbering function parameters and using
them as local variables is confusing at best and rarely improves code
readability.  Fix by using a local variable instead, no functionality
is changed.

This also renames the parameter from data to mime_data since the term
data is (soft) reserved for the easy handle struct.

Closes: #10046
Reviewed-by: Daniel Stenberg <daniel@haxx.se>
2022-12-08 23:45:18 +01:00
Ryan Schmidt
82b3481309
setup: do not require __MRC__ defined for Mac OS 9 builds
Partially reverts "somewhat protect Mac OS X users from using Mac OS 9
config file", commit 62519bfe059251af2914199f284c736553ff0489.

Do things that are specific to classic Mac OS (i.e. include config-mac.h
in curl_setup.h and rename "main" to "curl_main" in tool_setup.h) when
only "macintosh" is defined. Remove the additional condition that
"__MRC__" should be defined since that would only be true with the MPW
MrC compiler which prevents the use of other reasonable compilers like
the MPW SC compiler and especially the Metrowerks CodeWarrior compilers.
"macintosh" is only defined by classic Mac OS compilers so this change
should not affect users of Mac OS X / OS X / macOS / any other OS.

Closes #10037
2022-12-06 09:35:47 +01:00
Viktor Szakats
8fc2423338
Makefile.mk: address minor issues
- Fix `NROFF` auto-detection with certain shell/make-build combinations:

  When a non-MSYS2 GNU Make runs inside an MSYS2 shell, Make executes
  the detection command as-is via `CreateProcess()`. It fails because
  `command` is an `sh` built-in. Ensure to explicitly invoke the shell.

- Initialize user-customizable variables:

  Silences a list of warnings when running GNU Make with the option
  `--warn-undefined-variables`. Another benefit is that it's now easy
  to look up all user-customizable `Makefile.mk` variables by grepping
  for ` ?=` in the curl source tree.

  Suggested-by: Gisle Vanem
  Ref: https://github.com/curl/curl/pull/9764#issuecomment-1330674433

- Fix `MKDIR` invocation:

  Avoid a warning and potential issue in envs without forward-slash
  support.

Closes #10000
2022-12-02 15:20:41 +00:00
Daniel Stenberg
975efec61b
tool_operate: override the numeric locale and set "C" by force
Makes curl always use dot as decimal separator for options,
independently of what the locale says. Makes scripts and command lines
portable.

Updated docs accordingly.

Reported-by: Daniel Faust

Fixes #9969
Closes #9972
2022-11-25 08:32:23 +01:00