Bug 2871 - sftp client exits with zero exit status on error
Summary: sftp client exits with zero exit status on error
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sftp (show other bugs)
Version: 7.7p1
Hardware: Other Linux
: P5 enhancement
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks: V_7_8
  Show dependency treegraph
 
Reported: 2018-05-23 23:17 AEST by Petr Cerny [:hrosik]
Modified: 2021-04-23 15:02 AEST (History)
1 user (show)

See Also:


Attachments
sftp-client.c - transform return values to {-1, 0} consistently (1.15 KB, patch)
2018-05-23 23:17 AEST, Petr Cerny [:hrosik]
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Cerny [:hrosik] 2018-05-23 23:17:06 AEST
Created attachment 3154 [details]
sftp-client.c - transform return values to {-1, 0} consistently

From our bug report: 

--------
Our customer has found a small regression in sftp from OpenSSH 7.2p2. The sftp command returns exit code 0 when it fails to write the file due to the error "No space left on device". The customer has also tried to build the latest openssh version i.e. openssh-7.7p1 and tested it, but the problem persists.
--------

The culprit is:
commit 7d845f4a0b7ec97887be204c3760e44de8bf1f32
Author: djm@openbsd.org <djm@openbsd.org>
Date:   Wed Jan 14 13:54:13 2015 +0000

    upstream commit
    
    update sftp client and server to new buffer API. pretty
     much just mechanical changes; with & ok markus

It turns out it wasn't so mechanical after all - in some places the old code compares the return value against -1 to notice an error and gets positive integer SSH_FX_*.

I'm attaching patch from our L3. I'm not sure throwing away the specificity of errors is the best way, but since the present code doesn't seem to use the intermediate return values it makes things nicely consistent.
Comment 1 Damien Miller 2018-05-25 14:26:28 AEST
Thanks - applied. This will be in OpenSSH 7.8.
Comment 2 Damien Miller 2021-04-23 15:02:25 AEST
closing resolved bugs as of 8.6p1 release