From be703974e93ecb8ddf79f16485534d93be10a4e5 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Fri, 31 Aug 2018 15:57:58 +0200 Subject: [PATCH] buffer: Reformat buffer_shift() Signed-off-by: Andreas Schneider --- src/buffer.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/buffer.c b/src/buffer.c index f81a190b..743c9dc0 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -182,22 +182,27 @@ static int realloc_buffer(struct ssh_buffer_struct *buffer, size_t needed) { * @brief shifts a buffer to remove unused data in the beginning * @param buffer SSH buffer */ -static void buffer_shift(ssh_buffer buffer){ - uint32_t burn_pos = buffer->pos; +static void buffer_shift(ssh_buffer buffer) +{ + uint32_t burn_pos = buffer->pos; - buffer_verify(buffer); - if(buffer->pos==0) - return; - memmove(buffer->data, buffer->data + buffer->pos, buffer->used - buffer->pos); - buffer->used -= buffer->pos; - buffer->pos=0; + buffer_verify(buffer); - if (buffer->secure){ - void *ptr = buffer->data + buffer->used; - explicit_bzero(ptr, burn_pos); - } + if (buffer->pos == 0) { + return; + } + memmove(buffer->data, + buffer->data + buffer->pos, + buffer->used - buffer->pos); + buffer->used -= buffer->pos; + buffer->pos = 0; - buffer_verify(buffer); + if (buffer->secure) { + void *ptr = buffer->data + buffer->used; + explicit_bzero(ptr, burn_pos); + } + + buffer_verify(buffer); } /**