RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2187717 - Cannot upload files to Jscape SFTP server: file gets created empty
Summary: Cannot upload files to Jscape SFTP server: file gets created empty
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: curl
Version: 8.7
Hardware: All
OS: Linux
urgent
urgent
Target Milestone: rc
: ---
Assignee: Jacek Migacz
QA Contact: Daniel Rusek
URL:
Whiteboard:
: 2186138 (view as bug list)
Depends On:
Blocks: 2188029 2188030 2188031
TreeView+ depends on / blocked
 
Reported: 2023-04-18 14:05 UTC by Renaud Métrich
Modified: 2023-11-14 18:13 UTC (History)
6 users (show)

Fixed In Version: curl-7.61.1-33.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 2188029 2188030 2188031 (view as bug list)
Environment:
Last Closed: 2023-11-14 15:51:06 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-155052 0 None None None 2023-04-18 14:27:06 UTC
Red Hat Issue Tracker RHELPLAN-155053 0 None None None 2023-04-18 14:27:08 UTC
Red Hat Product Errata RHBA-2023:7158 0 None None None 2023-11-14 15:51:31 UTC

Description Renaud Métrich 2023-04-18 14:05:54 UTC
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

Comment 1 Renaud Métrich 2023-04-18 14:07:21 UTC
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< --------

Comment 2 Kamil Dudka 2023-04-18 14:12:38 UTC
Thank you for debugging it, Renaud!

Backport of the upstream patch in question was already requested in bug #2186138 last week.

Comment 5 Kamil Dudka 2023-04-19 11:28:33 UTC
*** Bug 2186138 has been marked as a duplicate of this bug. ***

Comment 8 Kamil Dudka 2023-04-20 07:52:47 UTC
CentOS Stream merge request:
https://gitlab.com/redhat/centos-stream/rpms/curl/-/merge_requests/29

Comment 15 errata-xmlrpc 2023-11-14 15:51:06 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (curl bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:7158


Note You need to log in before you can comment on or make changes to this bug.