Repository navigation
fix(libcurl): resolve curl_mime_filedata paths in the guest file namespace - #24585
oneandonlydean merged 1 commit into
Conversation
…space curl_mime_filedata handed the guest path to the host curl, which ran stat and fopen on it as a host path. /app0/... or /data/... was looked up at the host root, so the part failed with CURLE_READ_ERROR, or a host file at that path was sent. The path is now resolved as fopen resolves it, curl opens the host path, and the part's file name is the guest libc basename of the guest path, as curl takes it from the path it is given. A path that does not resolve leaves a file part that cannot be opened and returns CURLE_READ_ERROR, like a path that fails stat.
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 73a7a97879:
- Conventions:
tools/check_conventions.pypassed. - Build:
guest_curl_Transfers_testsbuilt cleanly. - CTest (
guest_curl_transfers):1/1 Test #5573: guest_curl_transfers ............. Passed 0.04 sec 100% tests passed, 0 tests failed out of 1 - Negative control: with
core/libs/prx/libcurl/Export.cppreverted tomainand the new tests kept, the suite fails:Restoring the change makes it pass again.1/1 Test #5573: guest_curl_transfers .............***Failed 0.13 sec 0% tests passed, 1 tests failed out of 1 - Code reading:
- Verified null safety in curl_mime_filedata_nid_postfix: if !part || !filename, delegates directly to host ::curl_mime_filedata(part, filename) and maintains part cleanup via ReplacePartContent
- Verified basename extraction: checked basename_r_nid_postfix(filename, base) buffer handling (1024 bytes) and length error throwing behavior conforming to FreeBSD/curl semantics
- Verified path resolution: checked ResolvePathError_nid_no_patch(filename, host) usage, handling unresolved guest paths by passing empty string to ::curl_mime_filedata which triggers stat failure and CURLE_READ_ERROR as expected
- Verified mime filename overriding: checked ::curl_mime_filename(part, base) setting the part filename to the guest basename rather than host path, and verified return code precedence when named != CURLE_OK
- Verified AGENTS.md compliance: debt fragment added under docs/dev/debt/changes/, conventional commit guidelines followed, no disallowed comments or special casing
Looks Good To Me
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — no blocking findings
The changed code appears consistent with the stated guest path handling, but I could not run the reported checks in this review environment.
What I ran
Inspected head 73a7a97879d28e3a882b96fddb2ee5d645d50e39 using repo_read.py for the prepared description, commit summary, manifest, diff, changed code hunks, and relevant helpers. No commands or tests were run.
Results
| Check | Result | Note |
|---|---|---|
| Changed code review | passed | Three changed files inspected |
| Automated checks | not run | No test execution available |
| Author-reported checks | not run | Windows test results are in the PR description |
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full contents of core/libs/prx/libcurl/Export.cpp and core/libs/prx/libcurl/tests/CurlTransfers.cpp were not read; only the changed hunks and directly relevant helpers were inspected. Linux and macOS behavior, and console curl basename behavior, remain unverified as noted in the PR description. The review folder's files.json was unavailable; manifest.json lists three changed files, all included. I read relevant sections of all three changed files.
To get this to a good state
Nothing is required. Optional: run the described tests on the target platforms and confirm console curl filename behavior.
What
curl_mime_filedatapassed the guest's path straight to the bundled curl 7.81.0, whosecurl_mime_filedatarunsstatandaccesson it and laterfopens it. Those are host calls, so a guest path such as/app0/upload.binor/data/report.dmpwas looked up at the host root (C:\app0\upload.binon Windows,/app0/upload.binon Linux): the call returnedCURLE_READ_ERROR, or, if a host file happened to exist at that path, curl sent the host file. libc'sfopenand FreeType'sFT_New_Facealready resolve guest paths withResolvePathError_nid_no_patch; this export did not.Now:
fopenresolves it, and curl is given the host path, so it stats, sizes and reads the file the guest named;basenameof the guest path, the name the console's curl would derive, rather than the base name of the host path;staton every host, so the part ends up as curl leaves any file it cannot stat: a file part that fails when opened, andCURLE_READ_ERROR;A base name too long for
basename's 1024-byte buffer throws: there FreeBSD'sbasenamereturns null and curl passes it tostrdup.The debt fragment records what is still open: whether the console's curl uses
basename(3)or curl's ownCurl_basename(which also splits at\), the ANSI-only file API of the Windows backend, and the paths that still go to curl untranslated (CURLFORM_FILE,CURLFORM_FILECONTENT, and options such asCURLOPT_CAINFOandCURLOPT_COOKIEFILE).Tested
Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release,
BUILD_TESTING=ON. Branch head73a7a97879onmainc8d5f91168.TestMimeFileGuestPathincore/libs/prx/libcurl/tests/CurlTransfers.cpp(guest_curl_transfers): writes a file through guestfopenat/anyps5-curl-mime-<n>.bin, attaches it withcurl_mime_filedata, posts the form to the test's loopback server and checks the part's body bytes andContent-Disposition: form-data; name="upload"; filename="anyps5-curl-mime-<n>.bin". It also checksCURLE_READ_ERRORfor a missing guest file and for a 300-byte name that does not resolve, and that such a part can then be given data and sent.mainc8f72e905c),guest_curl_transfersfails at thecurl_mime_filedatacall for the guest path. With the change it passes.ctest -R curl: the 11 libcurl tests pass after the rebase ontoc8d5f91168.guest_curl_slistmime, which attaches a file by a relative name, still passes: a relative guest name resolves against the guest working directory, which is the host's in that test.python tools/check_conventions.py --base origin/main,python tools/debt_fold.py --checkandgit diff --check origin/main...HEAD: clean.python tools/pr_overlap.py --names curl_mime_filedata:mainimplements it, no open pull request touches it.python tools/pr_overlap.py --branch fix/libcurl-mime-filedata-guest-pathlists fix(libcurl): pass CURLOPT_HTTPPOST forms to curl as host nodes #24542 (CURLOPT_HTTPPOSThost nodes), which adds its own transfer test at the same two places inCurlTransfers.cpp(beforemainand afterTestMimeBase64Transfer();): a textual overlap with no shared export, so whichever lands second rebases. It could not compare feat(libcurl): implement curl_formget #17661 (curl_formget, conflicting withmain); itsExport.cpphunks are in the form helpers andcurl_formadd, not near this export or the includes./anyps5-curl-mime-<n>.binat the host root); it was not run.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)