tool_operhlp: fix add_file_name_to_url() result on OOM#21011
tool_operhlp: fix add_file_name_to_url() result on OOM#21011vszakats wants to merge 5 commits intocurl:masterfrom
add_file_name_to_url() result on OOM#21011Conversation
add_file_name_to_url result in error branchesadd_file_name_to_url result on OOM
|
augment review |
🤖 Augment PR SummarySummary: Fixes error reporting in 🤖 Was this summary useful? React with 👍 or 👎 |
There was a problem hiding this comment.
Pull request overview
This PR updates the curl tool helper add_file_name_to_url() to report out-of-memory conditions accurately instead of incorrectly returning URL-format errors, while simplifying cleanup paths.
Changes:
- Default
add_file_name_to_url()failure result toCURLE_OUT_OF_MEMORYso OOM fromcurl_url(),curl_easy_escape(), orcurl_maprintf()is surfaced correctly. - Refactor early-return success path to reuse a shared cleanup label (
out:).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| uerr = curl_url_get(uh, CURLUPART_QUERY, &query, 0); | ||
| if(!uerr && query) { | ||
| curl_free(query); | ||
| curl_free(path); | ||
| curl_url_cleanup(uh); | ||
| return CURLE_OK; | ||
| result = CURLE_OK; | ||
| goto out; | ||
| } |
There was a problem hiding this comment.
@bagder what do you think of this suggestion? (a pre-existing issue, I'd
say it's justified, to bail out also in case of a lower-level OOM, i.e. char *part = curlx_memdup0(ptr, partlen);)
There was a problem hiding this comment.
It seems entirely accurate, yes. It should bail out on memory problems here.
There was a problem hiding this comment.
Had to back out from this, for it broke a lot of tests:
1b8a23f
Seems to be breaking a lot of tests:
https://github.com/curl/curl/actions/runs/23343096423/job/67901964263?pr=21011
FAIL 107: 'FTP PASV upload file' FTP, EPSV, STOR
FAIL 108: 'FTP PORT upload with CWD' FTP, PORT, STOR
FAIL 109: 'FTP PASV upload append' FTP, EPSV, APPE
FAIL 112: 'FTP PASV upload resume' FTP, EPSV, APPE, Resume
FAIL 123: 'FTP upload resume with whole file already downloaded' FTP, EPSV, Resume
FAIL 128: 'FTP upload with --crlf' FTP, EPSV, STOR, --crlf
FAIL 149: 'FTP with multiple uploads' FTP
FAIL 204: '"upload" with file://' FILE
FAIL 205: '"upload" nonexisting with file://' FILE, FAILURE
FAIL 216: 'FTP upload two files to the same dir' FTP
FAIL 235: 'FTP resumed upload but no file present remotely' FTP, STOR
FAIL 236: 'FTP resume upload but denied access to remote file' FTP
FAIL 247: 'FTP upload time condition evaluates TRUE => skip upload' FTP, MDTM
FAIL 248: 'FTP upload time condition evaluates FALSE => upload anyway' FTP, STOR, MDTM
FAIL 285: 'TFTP send' TFTP, TFTP WRQ
FAIL 286: 'TFTP send of boundary case 512 byte file' TFTP, TFTP WRQ
FAIL 289: 'FTP resume upload but denied access to local file' FTP, STOR, Resume, FAILURE
FAIL 348: 'FTP upload file with 552 disk full response' FTP, EPSV, STOR
FAIL 362: 'FTP resume upload file with nothing to start from' FTP, EPSV, STOR
FAIL 475: 'FTP PASV upload ASCII file' FTP, EPSV, STOR, TYPE A
FAIL 476: 'FTP PASV upload ASCII file already using CRLF' FTP, EPSV, STOR, TYPE A
FAIL 496: 'parallel upload missing file' curl tool, cmdline, parallel
FAIL 1007: 'TFTP send with invalid permission on server' TFTP, TFTP WRQ, FAILURE
FAIL 1038: 'FTP PASV upload resume from end of file' FTP, EPSV, APPE, Resume
FAIL 1039: 'FTP PASV upload resume from end of empty file' FTP, EPSV, APPE, Resume
FAIL 1243: 'TFTP send without TFTP options requests' TFTP, TFTP WRQ
FAIL 1291: 'Attempt to upload 1000 files but fail immediately' HTTP, HTTP PUT
FAIL 1490: '"upload" with file:// overwriting existing' FILE
add_file_name_to_url result on OOMadd_file_name_to_url() result on OOM
d03deed to
62cf58b
Compare
This reverts commit 62cf58b. Seems to be breaking a lot of tests: https://github.com/curl/curl/actions/runs/23343096423/job/67901964263?pr=21011 FAIL 107: 'FTP PASV upload file' FTP, EPSV, STOR FAIL 108: 'FTP PORT upload with CWD' FTP, PORT, STOR FAIL 109: 'FTP PASV upload append' FTP, EPSV, APPE FAIL 112: 'FTP PASV upload resume' FTP, EPSV, APPE, Resume FAIL 123: 'FTP upload resume with whole file already downloaded' FTP, EPSV, Resume FAIL 128: 'FTP upload with --crlf' FTP, EPSV, STOR, --crlf FAIL 149: 'FTP with multiple uploads' FTP FAIL 204: '"upload" with file://' FILE FAIL 205: '"upload" nonexisting with file://' FILE, FAILURE FAIL 216: 'FTP upload two files to the same dir' FTP FAIL 235: 'FTP resumed upload but no file present remotely' FTP, STOR FAIL 236: 'FTP resume upload but denied access to remote file' FTP FAIL 247: 'FTP upload time condition evaluates TRUE => skip upload' FTP, MDTM FAIL 248: 'FTP upload time condition evaluates FALSE => upload anyway' FTP, STOR, MDTM FAIL 285: 'TFTP send' TFTP, TFTP WRQ FAIL 286: 'TFTP send of boundary case 512 byte file' TFTP, TFTP WRQ FAIL 289: 'FTP resume upload but denied access to local file' FTP, STOR, Resume, FAILURE FAIL 348: 'FTP upload file with 552 disk full response' FTP, EPSV, STOR FAIL 362: 'FTP resume upload file with nothing to start from' FTP, EPSV, STOR FAIL 475: 'FTP PASV upload ASCII file' FTP, EPSV, STOR, TYPE A FAIL 476: 'FTP PASV upload ASCII file already using CRLF' FTP, EPSV, STOR, TYPE A FAIL 496: 'parallel upload missing file' curl tool, cmdline, parallel FAIL 1007: 'TFTP send with invalid permission on server' TFTP, TFTP WRQ, FAILURE FAIL 1038: 'FTP PASV upload resume from end of file' FTP, EPSV, APPE, Resume FAIL 1039: 'FTP PASV upload resume from end of empty file' FTP, EPSV, APPE, Resume FAIL 1243: 'TFTP send without TFTP options requests' TFTP, TFTP WRQ FAIL 1291: 'Attempt to upload 1000 files but fail immediately' HTTP, HTTP PUT FAIL 1490: '"upload" with file:// overwriting existing' FILE TESTFAIL: These test cases failed: 107 108 109 112 123 128 149 204 205 216 235 236 247 248 285 286 289 348 362 475 476 496 1007 1038 1039 1243 1291 1490
Return
CURLE_OUT_OF_MEMORYinstead ofCURLE_URL_MALFORMATwhencurl_url(),curl_easy_escape(), orcurl_maprintf()calls failed.Found by Codex Security
Also reuse deinit code from a success branch.