]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
os400: Fix IBMi EBCDIC conversion of arguments
authorandrewkirillov-ibm <akirillo@uk.ibm.com>
Wed, 13 Nov 2024 14:40:44 +0000 (14:40 +0000)
committerJay Satiro <raysatiro@yahoo.com>
Wed, 13 Nov 2024 23:21:29 +0000 (18:21 -0500)
- Fix the length of strings passed to iconv_open.

IBM's iconv_open expects parameters to be a pointer to a 32 byte
character array with the unused fields set to 0.

Prior to this change, since 8c62479a (precedes 8.11.0), it was
incorrectly passed pointers to smaller length const strings and curl
would fail with error "blank argument where content is expected".

Reported-by: Andrew Kirillov
Ref: https://www.ibm.com/docs/en/i/7.5?topic=ssw_ibm_i_75/apis/iconvopn.html

Fixes https://github.com/curl/curl/issues/15570
Closes https://github.com/curl/curl/pull/15574

packages/OS400/curlmain.c

index a36de32204de68ac01c1123fdca7553c99d56866..079b9b0d9dcda2e52844d14f894b664cca7bbd89 100644 (file)
@@ -61,8 +61,10 @@ int main(int argc, char **argv)
   size_t inbytesleft;
   size_t outbytesleft;
   char dummybuf[128];
-  const char *tocode = "IBMCCSID01208"; /* Use UTF-8. */
-  const char *fromcode = "IBMCCSID000000000010";
+  /* To/From codes are 32 byte long strings with
+     reserved fields initialized to ZEROs */
+  const char tocode[32]   = {"IBMCCSID01208"}; /* Use UTF-8. */
+  const char fromcode[32] = {"IBMCCSID000000000010"};
 
   ebcdic_argc = argc;
   ebcdic_argv = argv;