aboutsummaryrefslogtreecommitdiff
path: root/src/buffer.c
AgeCommit message (Collapse)AuthorFilesLines
2023-05-04buffer.c: Fix null pointer dereference errorNorbert Pocs1-1/+2
This issue was discovered by covscan tool. Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-11-23Add missing includes for fprintf()Andreas Schneider1-0/+1
src/init.c:118:9: warning: incompatible implicit declaration of built-in function 'fprintf' [enabled by default] fprintf(stderr, "Error in auto_init()\n"); ^ Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Norbert Pocs <npocs@redhat.com>
2022-10-07SSH_LOG_TRACE: Recategorize loglevelsNorbert Pocs1-3/+3
Do not print out logs when no fatal error happens. This approach is similiar to openssh, when Error/Fatal does not print recoverable error logs. recategorized based on - SSH_LOG_TRACE are debug logs when error happens Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-09-29buffer.c: Remove dot from documentation group definitionNorbert Pocs1-1/+1
Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-06-15Fix type mismatch warningsNorbert Pocs1-13/+14
Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-05-02Fix multiple spelling and grammar mistakesJunda Ai1-3/+3
Signed-off-by: Junda Ai <aijunda29@gmail.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-04-19trivial fix: Fixes some spelling errorsDhanuka Warusadura1-1/+1
Signed-off-by: Dhanuka Warusadura <csx@tuta.io> Reviewed-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-05-27Fixes typo in src/buffer.cSahana Prasad1-1/+1
Signed-off-by: Sahana Prasad <sahana@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-06-03buffer: Add NULL check for 'buffer' argumentAndreas Schneider1-0/+4
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-03buffer: Reformat ssh_buffer_add_data()Andreas Schneider1-17/+18
Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-09-24buffer: Simplify handling of the return codesJakub Jelen1-6/+2
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-09-24buffer: Avoid use of uninitialized valuesJakub Jelen1-6/+13
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-02-07buffer: Fix typo in a commentJakub Jelen1-1/+1
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-24buffer: Convert argc to size_t in ssh_buffer_unpack() as wellBaruch Siach1-12/+13
Commit c306a693f3fb ("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-24buffer: Support bignums in ssh_buffer_unpack()Aris Adamantiadis1-0/+20
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be> Reviewed-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-07buffer: Use size_t for argc argument in ssh_buffer_(un)pack()Andreas Schneider1-19/+19
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24buffer: Fix size comparison with countAndreas Schneider1-3/+3
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-20buffer: Don't call va_end() twiceAndreas Schneider1-1/+0
This is handled in the cleanup. Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-19buffer: Do cleanup if ssh_buffer_unpack() fails in the first loopAndreas Schneider1-1/+3
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-19buffer: Fix invalid memory access in ssh_buffer_unpack()Andreas Schneider1-4/+4
Found by oss-fuzz. Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-18buffer: Make sure unpack of secure buffers securely cleans upJakub Jelen1-4/+35
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17buffer: Reformat ssh_buffer_get_ssh_stringJakub Jelen1-25/+30
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17buffer: Fix typoJakub Jelen1-1/+1
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03buffer: Precalculate the size required for ssh_buffer_pack()Andreas Schneider1-0/+125
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03buffer: Only reduce the buffer size if it gets bigger than 64KAndreas Schneider1-2/+10
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03buffer: Only allow to allocate a maximum of 256MBAndreas Schneider1-0/+7
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03buffer: Always preallocate a buffer with 64 bytesAndreas Schneider1-27/+47
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03buffer: Rewrite ssh_buffer_free()Andreas Schneider1-12/+16
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03buffer: Use bool for secure bufferAndreas Schneider1-2/+18
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03buffer: Reformat buffer_shift()Andreas Schneider1-13/+18
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03buffer: Cleanup buffer_verifyAndreas Schneider1-18/+33
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-01buffer: Add and use ssh_buffer_allocate_size()Pino Toscano1-0/+28
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-06-29Rest in Peace SSHv1Andreas Schneider1-35/+0
Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-06-28Remove vim modelines from all filesAndreas Schneider1-2/+0
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-04buffer: Add ssh_buffer_allocate() functionAris Adamantiadis1-0/+38
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-04-18buffer: Do not call explicit_bzero with null argumentsNikos Mavrogiannopoulos1-1/+3
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-18buffer: Do not call memcpy with null argumentsNikos Mavrogiannopoulos1-3/+5
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-18buffer: Apply coding style to ssh_buffer_reinit()Andreas Schneider1-10/+12
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-04-18buffer: Apply coding style to realloc_buffer()Andreas Schneider1-30/+30
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-02-12src: Use explicit_bzero() if available on the platformAndreas Schneider1-5/+5
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-10-28Fix config.h includesAndreas Schneider1-2/+2
We need stdlib.h and string.h in priv.h for free() and memset(). Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-04-13buffer: Validate the length before before memory allocationAndreas Schneider1-2/+19
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-13buffer: Create ssh_buffer_validate_length()Andreas Schneider1-4/+28
This functions allows if a given length can be obtained from the buffer. Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-04-13Revert "buffer: Create ssh_buffer_validate_length()"Andreas Schneider1-21/+3
This reverts commit 34bdc1ca7871e8e9258077411edd516c8de55299.
2017-04-13Revert "buffer: Validate the length before before memory allocation"Andreas Schneider1-19/+2
This reverts commit 57550e6211c19c634a319bed59d39b28d020dcd1.
2017-04-13buffer: Validate the length before before memory allocationAndreas Schneider1-2/+19
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-13buffer: Create ssh_buffer_validate_length()Andreas Schneider1-3/+21
This functions allows if a given length can be obtained from the buffer. Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-02-06buffer: Use calloc to allocate a zero'ed bufferAndreas Schneider1-3/+3
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19buffer: expose ssh_buffer_get()Fabiano Fidêncio1-2/+0
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19buffer: expose ssh_buffer_{add,get}_data()Fabiano Fidêncio1-4/+0
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>