Junda Ai
41e2d17119
Fix multiple spelling and grammar mistakes
...
Signed-off-by: Junda Ai <aijunda29@gmail.com >
Reviewed-by: Jakub Jelen <jjelen@redhat.com >
2022-05-02 19:05:51 +02:00
Dhanuka Warusadura
3084b2bc41
trivial fix: Fixes some spelling errors
...
Signed-off-by: Dhanuka Warusadura <csx@tuta.io >
Reviewed-by: Jakub Jelen <jjelen@redhat.com >
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
2022-04-19 15:55:49 +02:00
Sahana Prasad
cfd883196d
Fixes typo in src/buffer.c
...
Signed-off-by: Sahana Prasad <sahana@redhat.com >
Reviewed-by: Jakub Jelen <jjelen@redhat.com >
2021-05-27 13:45:47 +02:00
Andreas Schneider
245ad744b5
buffer: Add NULL check for 'buffer' argument
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com >
Reviewed-by: Jakub Jelen <jjelen@redhat.com >
2020-06-03 10:40:06 +02:00
Andreas Schneider
10b3ebbe61
buffer: Reformat ssh_buffer_add_data()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com >
Reviewed-by: Jakub Jelen <jjelen@redhat.com >
2020-06-03 10:40:04 +02:00
Jakub Jelen
e72429f205
buffer: Simplify handling of the return codes
...
Signed-off-by: Jakub Jelen <jjelen@redhat.com >
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
2019-09-24 16:10:33 +02:00
Jakub Jelen
aff7c500d5
buffer: Avoid use of uninitialized values
...
Fixes the following oss-fuzz bug:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17565
Signed-off-by: Jakub Jelen <jjelen@redhat.com >
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
2019-09-24 16:06:38 +02:00
Jakub Jelen
82f4c6c607
buffer: Fix typo in a comment
...
Signed-off-by: Jakub Jelen <jjelen@redhat.com >
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
2019-02-07 10:30:05 +01:00
Baruch Siach
6c7eaa9e12
buffer: Convert argc to size_t in ssh_buffer_unpack() as well
...
Commit c306a693f3 ("buffer: Use size_t for argc argument in
ssh_buffer_(un)pack()") mentioned unpack in the commit log, but it only
touches the pack variants. Extend the conversion to unpack.
Pre-initialize the p pointer to avoid possible use before
initialization in case of early argc check failure.
This fixes build failure:
.../libssh-0.8.6/src/buffer.c: In function 'ssh_buffer_unpack_va':
.../libssh-0.8.6/src/buffer.c:1229:16: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
if (argc == -1){
^
Signed-off-by: Baruch Siach <baruch@tkos.co.il >
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
2019-01-24 17:48:08 +01:00
Aris Adamantiadis
a6c47099b7
buffer: Support bignums in ssh_buffer_unpack()
...
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be >
Reviewed-by: Jakub Jelen <jjelen@redhat.com >
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
2019-01-24 11:53:22 +01:00
Andreas Schneider
c306a693f3
buffer: Use size_t for argc argument in ssh_buffer_(un)pack()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2018-12-07 14:08:31 +01:00
Andreas Schneider
9c3ba94960
buffer: Fix size comparison with count
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2018-10-24 09:48:35 +02:00
Andreas Schneider
2ae2baf9ca
buffer: Don't call va_end() twice
...
This is handled in the cleanup.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2018-09-20 15:37:23 +02:00
Andreas Schneider
90373d8394
buffer: Do cleanup if ssh_buffer_unpack() fails in the first loop
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2018-09-19 11:18:12 +02:00
Andreas Schneider
07f7fa7806
buffer: Fix invalid memory access in ssh_buffer_unpack()
...
Found by oss-fuzz.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2018-09-19 11:18:02 +02:00
Jakub Jelen
86d521cbe7
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 >
2018-09-18 09:53:49 +02:00
Jakub Jelen
4d09c6dc31
buffer: Reformat ssh_buffer_get_ssh_string
...
Signed-off-by: Jakub Jelen <jjelen@redhat.com >
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
2018-09-17 16:39:38 +02:00
Jakub Jelen
039c066da5
buffer: Fix typo
...
Signed-off-by: Jakub Jelen <jjelen@redhat.com >
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
2018-09-17 16:39:38 +02:00
Andreas Schneider
c15bd2831f
buffer: Precalculate the size required for ssh_buffer_pack()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2018-09-03 18:32:12 +02:00
Andreas Schneider
efef877356
buffer: Only reduce the buffer size if it gets bigger than 64K
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2018-09-03 18:29:15 +02:00
Andreas Schneider
254a0f7132
buffer: Only allow to allocate a maximum of 256MB
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2018-09-03 18:27:32 +02:00
Andreas Schneider
d2131b286f
buffer: Always preallocate a buffer with 64 bytes
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2018-09-03 18:26:36 +02:00
Andreas Schneider
c1c32bda14
buffer: Rewrite ssh_buffer_free()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2018-09-03 18:19:58 +02:00
Andreas Schneider
a1b57d3b94
buffer: Use bool for secure buffer
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2018-09-03 15:00:53 +02:00
Andreas Schneider
be703974e9
buffer: Reformat buffer_shift()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2018-09-03 15:00:53 +02:00
Andreas Schneider
29f36791c9
buffer: Cleanup buffer_verify
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2018-09-03 15:00:53 +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