Andreas Schneider
1634c5a91a
buffer: Don't call va_end() twice
...
This is handled in the cleanup.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit 2ae2baf9ca )
2018-09-20 16:35:04 +02:00
Andreas Schneider
316a3a42a4
buffer: Do cleanup if ssh_buffer_unpack() fails in the first loop
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit 90373d8394 )
2018-09-19 11:56:10 +02:00
Andreas Schneider
546d9da185
buffer: Fix invalid memory access in ssh_buffer_unpack()
...
Found by oss-fuzz.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit 07f7fa7806 )
2018-09-19 11:56:09 +02:00
Jakub Jelen
8f18063b6d
buffer: Make sure unpack of secure buffers securely cleans up
...
Signed-off-by: Jakub Jelen <jjelen@redhat.com >
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit 86d521cbe7 )
2018-09-18 10:17:31 +02:00
Jakub Jelen
0e8f6aaee5
buffer: Reformat ssh_buffer_get_ssh_string
...
Signed-off-by: Jakub Jelen <jjelen@redhat.com >
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit 4d09c6dc31 )
2018-09-17 19:00:31 +02:00
Jakub Jelen
786d7e39a3
buffer: Fix typo
...
Signed-off-by: Jakub Jelen <jjelen@redhat.com >
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit 039c066da5 )
2018-09-17 19:00:31 +02:00
Andreas Schneider
574f279f00
buffer: Precalculate the size required for ssh_buffer_pack()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit c15bd2831f )
2018-09-03 19:04:13 +02:00
Andreas Schneider
d886870bbf
buffer: Only reduce the buffer size if it gets bigger than 64K
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit efef877356 )
2018-09-03 19:04:13 +02:00
Andreas Schneider
f56c93cccd
buffer: Only allow to allocate a maximum of 256MB
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit 254a0f7132 )
2018-09-03 19:04:13 +02:00
Andreas Schneider
bbd17bc97a
buffer: Always preallocate a buffer with 64 bytes
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit d2131b286f )
2018-09-03 19:04:13 +02:00
Andreas Schneider
26fa923b55
buffer: Rewrite ssh_buffer_free()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit c1c32bda14 )
2018-09-03 19:04:13 +02:00
Andreas Schneider
177a082974
buffer: Use bool for secure buffer
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit a1b57d3b94 )
2018-09-03 19:04:13 +02:00
Andreas Schneider
ce3ee332d4
buffer: Reformat buffer_shift()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit be703974e9 )
2018-09-03 19:04:13 +02:00
Andreas Schneider
eb95f8fa85
buffer: Cleanup buffer_verify
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit 29f36791c9 )
2018-09-03 19:04:13 +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
206f3ff895
Rest in Peace SSHv1
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
Reviewed-by: Jakub Jelen <jjelen@redhat.com >
2018-06-29 14:41:14 +02:00
Andreas Schneider
c563ed636a
Remove vim modelines from all files
...
If you want modelines use my vim plugin:
https://github.com/cryptomilk/git-modeline.vim
git config --add vim.modeline "ts=4 sw=4 et"
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2018-06-28 08:41:08 +02:00
Aris Adamantiadis
36d52ee205
buffer: Add ssh_buffer_allocate() function
...
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be >
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
2018-06-04 16:55:23 +02:00
Nikos Mavrogiannopoulos
3f562ee586
buffer: Do not call explicit_bzero with null arguments
...
This allows compiling and testing with undefined sanitizer.
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com >
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
2018-04-18 10:24:47 +02:00
Nikos Mavrogiannopoulos
eb796b4bbb
buffer: Do not call memcpy with null arguments
...
This allows compiling and testing with undefined sanitizer.
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com >
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
2018-04-18 10:24:42 +02:00
Andreas Schneider
87b8d232bd
buffer: Apply coding style to ssh_buffer_reinit()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2018-04-18 10:22:03 +02:00
Andreas Schneider
6f1f8d2bdb
buffer: Apply coding style to realloc_buffer()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2018-04-18 10:22:03 +02:00
Andreas Schneider
ebcff9fd63
src: Use explicit_bzero() if available on the platform
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2018-02-12 14:41:27 +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
Andreas Schneider
68b7ca6e92
buffer: Validate the length before before memory allocation
...
Check if the size the other party sent is a valid size in the
transmitted buffer.
Thanks to Alex Gaynor for finding and reporting the issue.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2017-04-13 16:25:40 +02:00
Andreas Schneider
c165c396de
buffer: Create ssh_buffer_validate_length()
...
This functions allows if a given length can be obtained from the buffer.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2017-04-13 16:25:29 +02:00
Andreas Schneider
f21ddefedb
Revert "buffer: Create ssh_buffer_validate_length()"
...
This reverts commit 34bdc1ca78 .
2017-04-13 16:19:28 +02:00
Andreas Schneider
0cf1c85542
Revert "buffer: Validate the length before before memory allocation"
...
This reverts commit 57550e6211 .
2017-04-13 16:19:23 +02:00
Andreas Schneider
57550e6211
buffer: Validate the length before before memory allocation
...
Check if the size the other party sent is a valid size in the
transmitted buffer.
Thanks to Alex Gaynor for finding and reporting the issue.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2017-04-13 16:12:27 +02:00
Andreas Schneider
34bdc1ca78
buffer: Create ssh_buffer_validate_length()
...
This functions allows if a given length can be obtained from the buffer.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2017-04-13 16:12:27 +02:00
Andreas Schneider
166b9f7709
buffer: Use calloc to allocate a zero'ed buffer
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2017-02-06 09:42:49 +01:00
Fabiano Fidêncio
5c5b1aaaa7
buffer: expose ssh_buffer_get()
...
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
6953c8ec91
buffer: expose ssh_buffer_{add,get}_data()
...
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
58aff4495e
buffer: expose ssh_buffer_reinit()
...
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
120d2b5333
buffer: remove ssh_buffer_get_begin()
...
Note that removing ssh_buffer_get_begin() doesn't break API
compatibility, as this functions has never been exposed (it only
has the LIBSSH_API prefix).
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
3cf72e5258
buffer: remove 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
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
9774b1062d
buffer: make ssh_buffer_get_len() call ssh_buffer_get_rest_len()
...
This is a preparatory step for having the behavior of
ssh_buffer_get_rest_len() in the ssh_buffer_get_len() and then remove
the ssh_buffer_rest_len()
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
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
56d0e91e10
buffer: cosmetic change in ssh_buffer_get_u8() documentation
...
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
d7349d04d0
buffer: fix documentation for ssh_buffer_get_u32()
...
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
Fabiano Fidêncio
6f60449e18
cleanup: use ssh_ prefix in the bignum (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
Andreas Schneider
41a10699e6
buffer: Make sure we do not use u32len uninitialized
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2016-01-19 11:09:06 +01:00
Andreas Schneider
33ecff11dd
buffer: Cleanup vaargs in ssh_buffer_unpack_va()
...
CID: #1267977
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2015-05-04 17:54:01 +02:00
Aris Adamantiadis
3091025472
buffers: Fix a possible null pointer dereference
...
This is an addition to CVE-2015-3146 to fix the null pointer
dereference. The patch is not required to fix the CVE but prevents
issues in future.
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be >
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
2015-04-23 10:33:52 +02:00
Aris Adamantiadis
940cb233ce
buffer: buffer_pack & unpack on non-gnu compilers
2015-02-08 18:49:32 +01:00
Andreas Schneider
ad8fa427dd
buffer: Abort if the canary is not intact in ssh_buffer_unpack()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be >
2015-02-02 17:32:34 +01:00
Andreas Schneider
de10a7754b
buffer: buffer: Improve argument checking of in ssh_buffer_pack()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be >
2015-02-02 17:32:31 +01:00
Andreas Schneider
6789170799
buffer: Abort if the canary is not intact in ssh_buffer_unpack()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be >
2015-02-02 17:32:28 +01:00