Andreas Schneider
12e94bfd18
sftp: Keep a ssh_packet for reading in the sftp handle
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit 79a3fcac72 )
2018-09-17 10:53:01 +02:00
Andreas Schneider
4fc3d7a27f
sftp: Remove ZERO_STRUCTP from sftp_free()
...
The structure doesn't hold any sensitive data and this would be
optimized away anyway.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit 945afaa6b4 )
2018-09-17 10:53:01 +02:00
Andreas Schneider
466bb332c1
sftp: Reformat sftp_free()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit d840a05be3 )
2018-09-17 10:53:01 +02:00
Andreas Schneider
ff25b45367
sftp: Reformat sftp_new()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit 662c30eb72 )
2018-09-17 10:53:01 +02:00
Andreas Schneider
37f451171b
sftp: Fix segfault in sftp_canonicalize_path()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit 4774d2b9f7 )
2018-09-04 19:00:47 +02:00
Andreas Schneider
73fbe68ccd
sftp: Use ssh_buffer_pack() in sftp_fstat()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit e601dbd8e3 )
2018-09-03 19:04:13 +02:00
Andreas Schneider
0cb282df99
sftp: Reformat sftp_lstat()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit f3ffd8aa41 )
2018-09-03 19:04:13 +02:00
Andreas Schneider
fdb0c0a29b
sftp: Use ssh_buffer_pack() in sftp_xstat()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit 4d98b1cd7e )
2018-09-03 19:04:13 +02:00
Andreas Schneider
2e56db3b2f
sftp: Reformat sftp_xstat()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit b00a0578f9 )
2018-09-03 19:04:13 +02:00
Andreas Schneider
4eb759bf40
sftp: Use ssh_buffer_unpack() in sftp_canonicalize_path()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit 336c097ae7 )
2018-09-03 19:04:13 +02:00
Andreas Schneider
c3987a9796
sftp: Use ssh_buffer_pack() in sftp_canonicalize_path()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit 1dd8466f66 )
2018-09-03 19:04:13 +02:00
Andreas Schneider
a070c942e7
sftp: Reformat sftp_canonicalize_path()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit 8b19ef05f3 )
2018-09-03 19:04:13 +02:00
Andreas Schneider
113b1872cf
sftp: Use sftp_buffer_pack() in sftp_fstatvfs()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit 7e11e41a9f )
2018-09-03 19:04:13 +02:00
Andreas Schneider
c7dc2937fc
sftp: Reformat sftp_fstatvfs()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit 5914ea7c75 )
2018-09-03 19:04:13 +02:00
Andreas Schneider
075895da40
sftp: Use ssh_buffer_pack() in sftp_fsync()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit f1e84d5e67 )
2018-09-03 19:04:13 +02:00
Andreas Schneider
7930086a37
sftp: Use ssh_buffer_pack() in sftp_statvfs()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit 8e3dd09e11 )
2018-09-03 19:04:13 +02:00
Andreas Schneider
3f376f848d
sftp: Reformat sftp_statvfs()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit ae0afec98d )
2018-09-03 19:04:13 +02:00
Andreas Schneider
3cee61a65b
sftp: Use ssh_buffer_unpack() in sftp_readlink()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit 0be43c333e )
2018-09-03 19:04:13 +02:00
Andreas Schneider
90321f732e
sftp: Use ssh_buffer_pack() in sftp_readlink()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit 83a5d3b258 )
2018-09-03 19:04:13 +02:00
Andreas Schneider
c6140b1a4c
sftp: Reformat sftp_readlink()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit bb4bdec184 )
2018-09-03 19:04:13 +02:00
Andreas Schneider
9290d89570
sftp: Use ssh_buffer_pack() in sftp_setstat()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit e0449ba21f )
2018-09-03 19:04:13 +02:00
Andreas Schneider
da9ab71f88
sftp: Reformat sftp_setstat()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit 8a56b90c3e )
2018-09-03 19:04:13 +02:00
Andreas Schneider
53dfee98d2
sftp: Use ssh_buffer_pack() in sftp_mkdir()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit 218c67a51d )
2018-09-03 19:04:13 +02:00
Andreas Schneider
bb14611f86
sftp: Reformat sftp_mkdir()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit 89c525bbf1 )
2018-09-03 19:04:13 +02:00
Andreas Schneider
b1aca92268
sftp: Use ssh_buffer_pack in sftp_open()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit 2c0baef7d4 )
2018-09-03 19:04:13 +02:00
Andreas Schneider
2b524655ae
sftp: Reformat sftp_open()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit bfb6718b50 )
2018-09-03 19:04:13 +02:00
Andreas Schneider
b51594c34a
sftp: Use ssh_buffer_pack() in sftp_handle_close()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit d99c066a0b )
2018-09-03 19:04:13 +02:00
Andreas Schneider
b409b7d092
sftp: Reformat sftp_handle_close()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit 2844942c1b )
2018-09-03 19:04:13 +02:00
Andreas Schneider
4256936fed
sftp: Use ssh_buffer_pack() in sftp_readdir()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit 3a729829fd )
2018-09-03 19:04:13 +02:00
Andreas Schneider
fdb6dc7069
sftp: Reformat sftp_readdir()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit 576fdbe1e8 )
2018-09-03 19:04:13 +02:00
Andreas Schneider
6291900234
sftp: Use ssh_buffer_pack() in sftp_opendir()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit 87df9cfc5d )
2018-09-03 19:04:13 +02:00
Andreas Schneider
216bd2abd8
sftp: Reformat sftp_opendir()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit ea375d1605 )
2018-09-03 19:04:13 +02:00
Andreas Schneider
0b688e4829
sftp: Use strndup()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit 509331ec81 )
2018-08-29 19:16:48 +02:00
Jakub Jelen
c9d0362a6b
sftp: Avoid race condition reading incomplete data messages
...
This changes amends f561e6bcb3 which
introduces same check in one place, but miss it in other two places.
We encountered this issue with qemu using SFTP to transfer large
data chunks and in some cases, the file transfer was interrupted
without any reason. From the debug messages, it showed up that
last part of data message/packet was not handled in the time
of the sftp_read() call, therefore the ssh_channel_read() returned
zero (there was no more data to read yet), which made the whole
transfer fail hard instead of retrying later.
The proposed change is reusing the code from previously referenced
commit also in the other places.
Signed-off-by: Jakub Jelen <jjelen@redhat.com >
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit ae3825dfb2 )
2018-08-27 09:30:14 +02:00
Jakub Jelen
54e7af83e6
sftp: Fix the debug message in sftp_enqueue()
...
This fixes the assignment of variables to comments and makes
the output symmetric with sftp_dequeue().
Signed-off-by: Jakub Jelen <jjelen@redhat.com >
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit a0214dfc9a )
2018-08-18 10:01:47 +02:00
Andreas Schneider
24aef4fbf1
sftp: Add missing size checks
...
CID 1238630
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2018-08-06 09:36:50 +02:00
Pino Toscano
12284b75fa
buffer: Add and use ssh_buffer_allocate_size()
...
Add a small helper for ssh_buffer to ensure that the buffer has a
certain amount of space already preallocated. This can be useful in case
it is known how much data is going to be added to a buffer, to avoid
multiple reallocations.
Make use of it in few places in the library.
Signed-off-by: Pino Toscano <ptoscano@redhat.com >
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
2018-08-01 11:04:33 +02:00
Andreas Schneider
f525fdb2e1
sftp: Check for NULL path and give correct error
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2017-11-09 11:41:58 +01:00
Andreas Schneider
f0ddde4826
Fix config.h includes
...
We need stdlib.h and string.h in priv.h for free() and memset().
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2017-10-28 14:31:37 +02:00
Pino Toscano
bc78383fac
sftp: Fix memory leak in sftp_fstat
...
When parsing the result of a successful fstat call, make sure to free
the resulting reply message.
Signed-off-by: Pino Toscano <ptoscano@redhat.com >
Reviewed-by: Andreas Schneider <asn@samba.org >
2016-10-22 16:03:33 +02:00
Tilo Eckert
1cc1a352fc
sftp: Add support for append in sftp_open()
...
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de >
2016-10-08 10:50:38 +02:00
Tilo Eckert
cfe7065ce1
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 >
2016-10-08 10:45:30 +02:00
Andreas Schneider
f561e6bcb3
sftp: Correctly check for EOF else keep spinning if there is no data
...
This fixes an issue introduced with
dbf72ffba2
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2016-10-07 13:36:58 +02:00
Andreas Schneider
155a155d1d
sftp: Add sftp_fsync() function
...
BUG: https://red.libssh.org/issues/141
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2016-10-06 16:26:52 +02:00
Jeremy Cross
dbf72ffba2
sftp: ensure sftp_packet_read recognizes channel EOF to avoid infinite loop
...
Signed-off-by: Jeremy Cross <jcross@bomgar.com >
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
2016-09-09 11:39:32 +02:00
Andreas Schneider
412c501442
sftp: Use calloc() instead of malloc()/memset()
...
This is calloc() is faster then calling memset().
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2016-05-04 14:56:22 +02:00
Fabiano Fidêncio
05fd0acf45
buffer: do not use ssh_buffer_get_rest_len()
...
As ssh_buffer_get_len() actually calls ssh_buffer_get_rest_len(), let's
just use the first one. This is a preparatory step for removing
ssh_buffer_get_rest_len().
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com >
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
2016-01-19 11:31:08 +01:00
Fabiano Fidêncio
954341dd1f
buffer: rename ssh_buffer_get_rest() to ssh_buffer_get()
...
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com >
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
2016-01-19 11:31:07 +01:00
Fabiano Fidêncio
adc8c20ac1
cleanup: use ssh_ prefix in the buffer (non-static) functions
...
Having "ssh_" prefix in the functions' name will avoid possible clashes
when compiling libssh statically.
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com >
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
2016-01-19 11:31:07 +01:00
Tilo Eckert
672c3be9ed
sftp: Fix incorrect handling of received length fields
...
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de >
2015-08-01 10:52:57 +03:00