Skip to content

tool_doswin: warn user that path is too long to be sanitized - #20121

Closed
jay wants to merge 5 commits into
curl:masterfrom
jay:warn_too_long_path_windows
Closed

jay wants to merge 5 commits into
curl:masterfrom
jay:warn_too_long_path_windows

Conversation

@jay

@jay jay commented Dec 31, 2025 •

Copy link
Copy Markdown
Member
  • Treat SANITIZE_ERR_INVALID_PATH in the calling function as CURLE_BAD_FUNCTION_ARGUMENT.

  • Warn via warnf with the reason that SANITIZE_ERR_INVALID_PATH is returned.

SANITIZE_ERR_ codes are not mapped directly to CURLE_ error codes which may have led to some confusion in certain cases so this change is an attempt to mitigate that.

Prior to this change some calling functions returned CURLE_URL_MALFORMAT for SANITIZE_ERR_INVALID_PATH even though the URL was not malformatted.

Bug: https://github.com/curl/curl/pull/20113/changes#r2652697794
Reported-by: Viktor Szakats

Closes #xxxxx

- Treat SANITIZE_ERR_INVALID_PATH in the calling function as
  CURLE_BAD_FUNCTION_ARGUMENT.

- Warn in the sanitizer function via warnf with the reason that
  SANITIZE_ERR_INVALID_PATH is returned.

SANITIZE_ERR_ codes are not mapped directly to CURLE_ error codes which
may have led to some confusion in certain cases so this change is an
attempt to mitigate that.

Prior to this change some calling functions returned CURLE_URL_MALFORMAT
for SANITIZE_ERR_INVALID_PATH even though the URL was not malformatted.

Bug: https://github.com/curl/curl/pull/20113/changes#r2652697794
Reported-by: Viktor Szakats

Closes #xxxxx
@testclutch

Copy link
Copy Markdown

Analysis of PR #20121 at d426ec21:

Test ../../tests/http/test_07_upload.py::TestUpload::test_07_70_put_earlydata[h3-limited-body] failed, but it has been 0.9% flaky lately, so it's probably NOT a fault of the PR. Note that this test has failed in 2 different CI jobs (the link just goes to one of them).

Test 1604 failed, which has NOT been flaky recently, so there could be a real issue in this PR. Note that this test has failed in 72 different CI jobs (the link just goes to one of them).

Generated by Testclutch

@jay

jay commented Dec 31, 2025 •

Copy link
Copy Markdown
Member Author

I need to rethink this, I can't run the unit test and have warnf failures without doing some tool initialization (otherwise segfault probably due to missing tool_stderr init). It will probably be easier to have a generic path invalid message in the calling function instead of handling individual reasons for the path invalid (which is only path too long, really)

edit: revised in most recent push

@jay
jay force-pushed the warn_too_long_path_windows branch from df11593 to 8a29954 Compare December 31, 2025 08:30
@jay

jay commented Jan 3, 2026

Copy link
Copy Markdown
Member Author

#20143 sort of renders this PR moot so unless anyone thinks we still need the extra warning (for MS-DOS) I'm going to close it

@bagder

bagder commented Jan 4, 2026

Copy link
Copy Markdown
Member

I think we can close

@jay

jay commented Jan 4, 2026

Copy link
Copy Markdown
Member Author

Closing in favor of #20143

@jay jay closed this Jan 4, 2026
vszakats added a commit that referenced this pull request Jan 10, 2026
…n fails

On MS-DOS (OOM and bad filename) and Windows (OOM only).

Given the rarity of both platform and error, we make a compromise and
return an unrelated libcurl error (43) in case of a bad output filename
on MS-DOS.

After:
```
$ CURL_FN_SANITIZE_OOM=1 wine curl.exe https://curl.se/ --output out.txt
curl: (27) Out of memory

$ CURL_FN_SANITIZE_BAD=1 wine curl.exe https://curl.se/ --output out.txt
Warning: bad output filename
curl: (43) A libcurl function was given a bad argument

$ CURL_FN_SANITIZE_OOM=1 wine curl.exe https://curl.se/index.html --globoff -O
curl: (27) Out of memory

$ CURL_FN_SANITIZE_BAD=1 wine curl.exe https://curl.se/index.html --globoff -O
curl: bad output filename
curl: (43) A libcurl function was given a bad argument
```

Before:
```
$ CURL_FN_SANITIZE_OOM=1 wine curl.exe https://curl.se/ --output out.txt
Warning: bad output glob
curl: (27) Out of memory

$ CURL_FN_SANITIZE_BAD=1 wine curl.exe https://curl.se/ --output out.txt
Warning: bad output glob
curl: (3) URL using bad/illegal format or missing URL

$ CURL_FN_SANITIZE_OOM=1 wine curl.exe https://curl.se/index.html --globoff -O
curl: Failed to extract a filename from the URL to use for storage
curl: (27) Out of memory

$ CURL_FN_SANITIZE_BAD=1 wine curl.exe https://curl.se/index.html --globoff -O
curl: Failed to extract a filename from the URL to use for storage
curl: (3) URL using bad/illegal format or missing URL
```

Ref: #20116 (simpler reboot of)
Ref: #20113 #20121
Ref: 40c1748 #20198
Ref: eb7f5b7 #20143
Ref: 8c02407 #20125
Fixes #20044
Closes #20199
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cmdline tool Windows Windows-specific

Development

Successfully merging this pull request may close these issues.

3 participants