From: Guy Harris Date: Tue, 29 Aug 2017 18:29:26 +0000 (-0700) Subject: Update print-esp.c X-Git-Tag: tcpdump-4.9.2~142 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/0e75ea93931bdcf76a3b39db14d6959f81509ca2?ds=sidebyside Update print-esp.c --- 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);