aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTilo Eckert <tilo.eckert@flam.de>2015-07-22 15:26:56 +0200
committerAndreas Schneider <asn@cryptomilk.org>2015-07-30 10:46:34 +0200
commit267fe0208814898e1dff5dd401cbb049ebb9a2f5 (patch)
treeb0098b3918ed28c1a51d1929f2bc77299171d621
parent52b5258ed4837608e35f24df0fb5ea5abc0a4e14 (diff)
downloadlibssh-267fe0208814898e1dff5dd401cbb049ebb9a2f5.tar.gz
libssh-267fe0208814898e1dff5dd401cbb049ebb9a2f5.tar.xz
libssh-267fe0208814898e1dff5dd401cbb049ebb9a2f5.zip
fix file mode checks in sftp_open()
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--src/sftp.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/sftp.c b/src/sftp.c
index e925b526..ae7b7efe 100644
--- a/src/sftp.c
+++ b/src/sftp.c
@@ -1638,18 +1638,17 @@ 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)
- sftp_flags |= SSH_FXF_READ; /* if any of the other flag is set,
- READ should not be set initialy */
- if (flags & O_WRONLY)
+ 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)
+ if ((flags & O_RDWR) == O_RDWR)
sftp_flags |= (SSH_FXF_WRITE | SSH_FXF_READ);
- if (flags & O_CREAT)
+ if ((flags & O_CREAT) == O_CREAT)
sftp_flags |= SSH_FXF_CREAT;
- if (flags & O_TRUNC)
+ if ((flags & O_TRUNC) == O_TRUNC)
sftp_flags |= SSH_FXF_TRUNC;
- if (flags & O_EXCL)
+ if ((flags & O_EXCL) == O_EXCL)
sftp_flags |= SSH_FXF_EXCL;
SSH_LOG(SSH_LOG_PACKET,"Opening file %s with sftp flags %x",file,sftp_flags);
id = sftp_get_new_id(sftp);