aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStefanBruens <stefan.bruens@rwth-aachen.de>2020-04-09 17:54:55 +0000
committerJakub Jelen <jjelen@redhat.com>2020-04-15 13:21:28 +0200
commit1ff6dda616ecb6327256003d5c0ee7ddd40bc783 (patch)
tree2d31e7727c8abd9380afc9956643beea2597ca6b /src
parente3e3a2786362f89fc72cd8a8a67fd52a435a1597 (diff)
downloadlibssh-1ff6dda616ecb6327256003d5c0ee7ddd40bc783.tar.gz
libssh-1ff6dda616ecb6327256003d5c0ee7ddd40bc783.tar.xz
libssh-1ff6dda616ecb6327256003d5c0ee7ddd40bc783.zip
Correctly parse v4 subsecond timestamps
All subsecond timestamps are only in the packets if both the SUBSECOND_TIMES flag and the timestamp flag, e.g. ATTR_ACCESSTIME are set. SUBSECOND_TIMES are not very common across server implementations (e.g. openssh does not include it, nor does libssh's sftpserver implementation), but this interpretation of the SFTP protocol draft is used by WinSCP and lftp. Fixes T219. Signed-off-by: Stefan BrĂ¼ns <stefan.bruens@rwth-aachen.de> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/sftp.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/sftp.c b/src/sftp.c
index c6d095a3..53582f45 100644
--- a/src/sftp.c
+++ b/src/sftp.c
@@ -1173,13 +1173,13 @@ static sftp_attributes sftp_parse_attr_4(sftp_session sftp, ssh_buffer buf,
break;
}
attr->atime64 = ntohll(attr->atime64);
- }
- if (flags & SSH_FILEXFER_ATTR_SUBSECOND_TIMES) {
- if (ssh_buffer_get_u32(buf, &attr->atime_nseconds) != 4) {
- break;
+ if (flags & SSH_FILEXFER_ATTR_SUBSECOND_TIMES) {
+ if (ssh_buffer_get_u32(buf, &attr->atime_nseconds) != 4) {
+ break;
+ }
+ attr->atime_nseconds = ntohl(attr->atime_nseconds);
}
- attr->atime_nseconds = ntohl(attr->atime_nseconds);
}
if (flags & SSH_FILEXFER_ATTR_CREATETIME) {
@@ -1187,13 +1187,13 @@ static sftp_attributes sftp_parse_attr_4(sftp_session sftp, ssh_buffer buf,
break;
}
attr->createtime = ntohll(attr->createtime);
- }
- if (flags & SSH_FILEXFER_ATTR_SUBSECOND_TIMES) {
- if (ssh_buffer_get_u32(buf, &attr->createtime_nseconds) != 4) {
- break;
+ if (flags & SSH_FILEXFER_ATTR_SUBSECOND_TIMES) {
+ if (ssh_buffer_get_u32(buf, &attr->createtime_nseconds) != 4) {
+ break;
+ }
+ attr->createtime_nseconds = ntohl(attr->createtime_nseconds);
}
- attr->createtime_nseconds = ntohl(attr->createtime_nseconds);
}
if (flags & SSH_FILEXFER_ATTR_MODIFYTIME) {
@@ -1201,13 +1201,13 @@ static sftp_attributes sftp_parse_attr_4(sftp_session sftp, ssh_buffer buf,
break;
}
attr->mtime64 = ntohll(attr->mtime64);
- }
- if (flags & SSH_FILEXFER_ATTR_SUBSECOND_TIMES) {
- if (ssh_buffer_get_u32(buf, &attr->mtime_nseconds) != 4) {
- break;
+ if (flags & SSH_FILEXFER_ATTR_SUBSECOND_TIMES) {
+ if (ssh_buffer_get_u32(buf, &attr->mtime_nseconds) != 4) {
+ break;
+ }
+ attr->mtime_nseconds = ntohl(attr->mtime_nseconds);
}
- attr->mtime_nseconds = ntohl(attr->mtime_nseconds);
}
if (flags & SSH_FILEXFER_ATTR_ACL) {