Description of problem: We have a customer reporting a bug with curl on RHEL 8.7.0: any transfer to their Jscape SFTP server creates the file but empty, the content is not copied. RHEL 9.1.0 curl works fine. Digging into this, it appears that there is a bug when setting the flags: -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< -------- 546 static CURLcode myssh_statemach_act(struct connectdata *conn, bool *block) 547 { : 1114 /* Clear file before writing (normal behaviour) */ 1115 flags = O_WRONLY|O_APPEND|O_CREAT|O_TRUNC; : 1119 sshc->sftp_file = 1120 sftp_open(sshc->sftp_session, protop->path, 1121 flags, (mode_t)data->set.new_file_perms); 1122 if(!sshc->sftp_file) { 1123 err = sftp_get_error(sshc->sftp_session); -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< -------- The flags state to O_APPEND + O_TRUNC, which is considered as an error on the Jscape SFTP server side. This makes libssh fail to return a handle on line 1119 and "err" to be set to 4 ("Generic Error"). RHEL9 code is fixed, the flags line doesn't have O_APPEND anymore: -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< -------- 1237 flags = O_WRONLY|O_CREAT|O_TRUNC; -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< -------- Version-Release number of selected component (if applicable): libcurl-7.61.1-25.el8_7.3.x86_64 How reproducible: Always when connection to customer system
I could confirm that live-patching curl fixes the issue: -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< -------- # stap -v -g -e 'probe process("/usr/lib64/libcurl.so.4.5.0").statement("myssh_statemach_act@../../lib/ssh-libssh.c:1117") { if ($flags == 1601) $flags = 577 }' -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
Thank you for debugging it, Renaud! Backport of the upstream patch in question was already requested in bug #2186138 last week.
*** Bug 2186138 has been marked as a duplicate of this bug. ***
CentOS Stream merge request: https://gitlab.com/redhat/centos-stream/rpms/curl/-/merge_requests/29