Conversation
There was a problem hiding this comment.
Pull request overview
Reworks OS/400 CCSID conversion wrappers around dynbuf and libcurl allocators.
Changes:
- Adds iterative
iconv()conversion throughdyn_addn_CCSID(). - Migrates wrappers to dynamic buffers and libcurl memory allocation.
- Updates CCSID handling across forms, MIME, options, URLs, and headers.
Suppressed comments (5)
projects/OS400/ccsidcurl.c:339
- Reject negative lengths before passing this value to
dyn_addn_CCSID. Except for-1, a negativeintis converted to a huge finitesize_t, causingiconv()to read beyondstring; the underlyingcurl_easy_escape()contract rejects negative lengths.
if(!string)
return NULL;
projects/OS400/ccsidcurl.c:1385
- This introduces an approximately 8 MB ceiling for MIME memory payloads:
dyn_addn_CCSID()returnsCURLE_TOO_LARGEonce the converted bytes plus its temporary terminator exceed this bound.curl_mime_data()accepts arbitrarysize_tpayload lengths, and the previous implementation sized the conversion buffer fromdatasize, so larger valid MIME parts now fail. Derive the dynbuf bound from the finitedatasizewith checked arithmetic (while handlingCURL_ZERO_TERMINATEDseparately).
curlx_dyn_init(&db, CURL_MAX_INPUT_LENGTH);
result = dyn_addn_CCSID(&db, data, datasize, ccsid, ASCII_CCSID);
projects/OS400/ccsidcurl.c:1071
- The fixed
CURL_MAX_INPUT_LENGTHbound now applies to both explicitly sizedCURLOPT_COPYPOSTFIELDSdata and blob options using this shared buffer. Those APIs can carry payloads larger than 8 MB, and the old implementation allocated from the supplied payload length; such calls now fail withCURLE_TOO_LARGE. Size the conversion buffer from the payload length in the relevant switch branch, with checked expansion and terminator space.
curlx_dyn_init(&db, CURL_MAX_INPUT_LENGTH);
projects/OS400/ccsidcurl.c:375
- This path needs finite validated lengths at both conversion stages. A negative
lengthbelow-1becomes a hugesize_there and can makeiconv()read paststring; after unescaping,%00can produce embedded NUL bytes that are truncated by the laterCURL_ZERO_TERMINATEDconversion. Reject negative input lengths, capture the decoded byte count locally, and convert exactly that many bytes.
if(dyn_addn_CCSID(&db, string, length ? length : CURL_ZERO_TERMINATED,
ccsidin, ASCII_CCSID))
return NULL;
d = curl_easy_unescape(handle,
projects/OS400/ccsidcurl.c:735
- This hard-caps explicitly sized legacy form data conversion at roughly 8 MB, although form content lengths are payload sizes and the previous code allocated from that supplied length. Large valid
CURLFORM_CONTENTSLENGTH/CURLFORM_CONTENTLENvalues therefore regress to a conversion failure. For finite lengths, initialize the dynbuf from the checked input length rather than the generic string-input limit.
curlx_dyn_init(&db, CURL_MAX_INPUT_LENGTH);
if(lengthx >= 0)
len = (size_t) forms[lengthx].value;
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The issue is more global: continuous never-ending housekeeping interferes with code development/fix. There should be periods for this, a bit like we have "feature freeze". Just a suggestion trying to make everyone happy.
Yes: this is so nowadays because it has been silently bulk-changed everywhere.
If you think it is part of the style, please write it down, and add it to
As I wrote before, I'm not against rules (providing they are not too constraining for the developer), but they have to be explicit and accessible as a reference. New ones should be advertised. The target swap occurred because I started edition before the bulk-change that suppressed the space: it was then lost in hundreds of conflicts. The program compiles, runs and is readable anyway, which is IMHO the main goal of a project. Such make-time undetected details (without minimizing the janitor's work) should not be subject to moaning. just to be adapted if judicious. When something breaks on the OS400 because other contributor can't try compiling it, I just fix it afterwards when detected (i.e.: see 64c03bb) because this falls to me, although other developers kindly try to improve OS400 code blindly. Likewise, I try to do my best on others' targets, but you have to admit by analogy it is hard to respect something unspecified and unchecked you're not specialized on and escapes a minded logic. It is also hard to determine which latitude has a developer for creation if rules are not explicit. |
Function dyn_addn_CCSID() extends dynbuf strings to arbitrary encodings, possibly multi-byte. It converts the input data using iterative iconv() calls and appends the converted characters to the dynbuf string. Most EBCDIC wrappers are now based on this function. All memory allocations in these wrappers are now performed via the libcurl malloc interface.
Done.
I have not figured out how to do that. It requires quite complicated parsing and analysis beyond what the script is currently doing. |
Thanks. On my side, all casts in this PR have been changed.
What about something like May I suggest such rule change/addition be advertised on the mailing list ? |
|
Thanks for merge. |
This is a reopening of #21129