Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EBCDIC conversion of argments on IBMi(OS400) is broken #15570

Closed
andrewkirillov-ibm opened this issue Nov 13, 2024 · 3 comments
Closed

EBCDIC conversion of argments on IBMi(OS400) is broken #15570

andrewkirillov-ibm opened this issue Nov 13, 2024 · 3 comments

Comments

@andrewkirillov-ibm
Copy link
Contributor

I did this

I compiled 8.11.0 release on IBM i V7R4M0 system. For this I applied a fix suggested in #15566, as the released version does not build on IBMi. However CURL does not seem to be function well.

> ./curl --version                                                 
  curl: option : blank argument where content is expected          
  curl: try 'curl --help' or 'curl --manual' for more information  
  $                                                                
> ./curl www.google.com                                            
  curl: option : blank argument where content is expected          
  curl: try 'curl --help' or 'curl --manual' for more information  

The reason for this is the fix to #15214. As a result of it iconv_open() fails to initialize conversion. The IBMi docs say that both to/from conversion codes are 32 byte long strings. And all reserved fields MUST be set to zeros.
https://www.ibm.com/docs/en/i/7.5?topic=ssw_ibm_i_75/apis/iconvopn.html

I expected the following

I expect CURL command to handle command line arguments correctly on IBMi/OS400 platform.

curl/libcurl version

8.11.0

operating system

OS400 V7R4M0

@andrewkirillov-ibm
Copy link
Contributor Author

andrewkirillov-ibm commented Nov 13, 2024

The fix below fixes CURL so it does work fine on IBMi.
packages/OS400/curlmain.c

@@ -59,12 +59,14 @@ int main(int argc, char **argv)
   char *inbuf;
   char *outbuf;
   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;
 
   /* Build the encoding converter. */

@bagder
Copy link
Member

bagder commented Nov 13, 2024

Any chance you can provide this patch as a full fledged PR?

@andrewkirillov-ibm
Copy link
Contributor Author

Will work on it.

andrewkirillov-ibm added a commit to andrewkirillov-ibm/curl that referenced this issue Nov 13, 2024
Fixing issue curl#15570, where IBMi EBCDIC conversion of command line arguments got broken.
@jay jay closed this as completed in 0b3b61c Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants