diff options
author | Tilo Eckert <tilo.eckert@flam.de> | 2016-06-30 12:27:43 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2016-10-08 10:45:30 +0200 |
commit | cfe7065ce16511521d68b864398d1da0f0c5130e (patch) | |
tree | 420d5a6fccd40e18b76bb158ec946124b92c6ae6 /src/sftp.c | |
parent | f561e6bcb361999088fe377f750dbacbc5e0102f (diff) | |
download | libssh-cfe7065ce16511521d68b864398d1da0f0c5130e.tar.gz libssh-cfe7065ce16511521d68b864398d1da0f0c5130e.tar.xz libssh-cfe7065ce16511521d68b864398d1da0f0c5130e.zip |
sftp: Do not always set SSH_FXF_READ
Comparison ((flags & O_RDONLY) == O_RDONLY) is always true.
Also, O_RDWR, O_WRONLY and O_RDONLY are mutually exclusive => no need to check all of them
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
Diffstat (limited to 'src/sftp.c')
-rw-r--r-- | src/sftp.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -1626,12 +1626,13 @@ sftp_file sftp_open(sftp_session sftp, const char *file, int flags, attr.permissions = mode; attr.flags = SSH_FILEXFER_ATTR_PERMISSIONS; - if ((flags & O_RDONLY) == O_RDONLY) - sftp_flags |= SSH_FXF_READ; - if ((flags & O_WRONLY) == O_WRONLY) - sftp_flags |= SSH_FXF_WRITE; - if ((flags & O_RDWR) == O_RDWR) + if ((flags & O_RDWR) == O_RDWR) { sftp_flags |= (SSH_FXF_WRITE | SSH_FXF_READ); + } else if ((flags & O_WRONLY) == O_WRONLY) { + sftp_flags |= SSH_FXF_WRITE; + } else { + sftp_flags |= SSH_FXF_READ; + } if ((flags & O_CREAT) == O_CREAT) sftp_flags |= SSH_FXF_CREAT; if ((flags & O_TRUNC) == O_TRUNC) |