From b19c83b54e688461fe0cc3a6e77fb3ca86ee9a3c Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Tue, 29 Aug 2017 11:29:26 -0700 Subject: [PATCH] Update print-esp.c --- print-esp.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/print-esp.c b/print-esp.c index 9ac7d0be..748fb4a1 100644 --- a/print-esp.c +++ b/print-esp.c @@ -734,19 +734,19 @@ esp_print(netdissect_options *ndo, p = ivoff; EVP_CipherInit(ctx, NULL, NULL, p, 0); - len = ep - (p + ivlen); - - /* We need a block size */ - block_size = EVP_CIPHER_CTX_block_size(ctx); - /* We need the buffer size to be multiple of a block size */ - output_buffer_size = len + (block_size - len % block_size); - output_buffer = (u_char *)calloc(output_buffer_size, sizeof(u_char)); - /* EVP_Cipher output buffer should be different from the input one. - * Also it should be of size that is multiple of cipher block size. */ - EVP_Cipher(ctx, output_buffer, p + ivlen, len); + len = ep - (p + ivlen); + + /* We need a block size */ + block_size = EVP_CIPHER_CTX_block_size(ctx); + /* We need the buffer size to be multiple of a block size */ + output_buffer_size = len + (block_size - len % block_size); + output_buffer = (u_char *)calloc(output_buffer_size, sizeof(u_char)); + /* EVP_Cipher output buffer should be different from the input one. + * Also it should be of size that is multiple of cipher block size. */ + EVP_Cipher(ctx, output_buffer, p + ivlen, len); EVP_CIPHER_CTX_free(ctx); - memcpy(p + ivlen, output_buffer, len); - free(output_buffer); + memcpy(p + ivlen, output_buffer, len); + free(output_buffer); advance = ivoff - (const u_char *)esp + ivlen; } else advance = sizeof(struct newesp); -- 2.39.5