diff options
| author | Alan Dunn <amdunn@gmail.com> | 2014-02-06 08:12:46 -0600 |
|---|---|---|
| committer | Andreas Schneider <asn@cryptomilk.org> | 2014-02-06 19:40:09 +0100 |
| commit | e7f831f0a3368b9c39eb838bb2f6ca266cb8e62c (patch) | |
| tree | e072d2e0208c19b0517d91e8700b99adc79117c2 /include/libssh/ssh2.h | |
| parent | 4ea4e12df2a65b1d5cd913965461ac3e56ebc946 (diff) | |
packet: Do not decrypt zero length rest of buffer
If we receive a packet of length exactly blocksize, then
packet_decrypt gets called on a buffer of size 0. The check at the
beginning of packet_decrypt indicates that the function should be
called on buffers of at least one blocksize, though the check allows
through zero length. As is packet_decrypt can return -1 when len is 0
because malloc can return NULL in this case: according to the ISO C
standard, malloc is free to return NULL or a pointer that can be freed
when size == 0, and uclibc by default will return NULL here (in
"non-glibc-compatible" mode). The net result is that when using
uclibc connections with libssh can anomalously fail.
Alternatively, packet_decrypt (and probably packet_encrypt for
consistency) could be made to always succeed on len == 0 without
depending on the behavior of malloc.
Thanks to Josh Berlin for bringing conneciton failures with uclibc to
my attention.
Signed-off-by: Alan Dunn <amdunn@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'include/libssh/ssh2.h')
0 files changed, 0 insertions, 0 deletions
