From a1b57d3b94491e0fca85513d18bd1c02b1835284 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Fri, 31 Aug 2018 15:42:35 +0200 Subject: [PATCH] buffer: Use bool for secure buffer Signed-off-by: Andreas Schneider --- include/libssh/buffer.h | 14 -------------- src/buffer.c | 20 ++++++++++++++++++-- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/include/libssh/buffer.h b/include/libssh/buffer.h index 2119f2cc..4721cbe0 100644 --- a/include/libssh/buffer.h +++ b/include/libssh/buffer.h @@ -24,20 +24,6 @@ #include #include "libssh/libssh.h" -/* - * Describes a buffer state - * [XXXXXXXXXXXXDATA PAYLOAD XXXXXXXXXXXXXXXXXXXXXXXX] - * ^ ^ ^ ^] - * \_data points\_pos points here \_used points here | / - * here Allocated - */ -struct ssh_buffer_struct { - char *data; - uint32_t used; - uint32_t allocated; - uint32_t pos; - int secure; -}; #define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3) diff --git a/src/buffer.c b/src/buffer.c index 743c9dc0..c4fdc752 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -37,6 +37,21 @@ #include "libssh/misc.h" #include "libssh/bignum.h" +/* + * Describes a buffer state + * [XXXXXXXXXXXXDATA PAYLOAD XXXXXXXXXXXXXXXXXXXXXXXX] + * ^ ^ ^ ^] + * \_data points\_pos points here \_used points here | / + * here Allocated + */ +struct ssh_buffer_struct { + bool secure; + char *data; + uint32_t used; + uint32_t allocated; + uint32_t pos; +}; + /** * @defgroup libssh_buffer The SSH buffer functions. * @ingroup libssh @@ -137,8 +152,9 @@ void ssh_buffer_free(struct ssh_buffer_struct *buffer) { * * @param[in] buffer buffer to set secure. */ -void ssh_buffer_set_secure(ssh_buffer buffer){ - buffer->secure = 1; +void ssh_buffer_set_secure(ssh_buffer buffer) +{ + buffer->secure = true; } static int realloc_buffer(struct ssh_buffer_struct *buffer, size_t needed) {