From 495d8cadd04656f263185c37c0c86c5650be5b28 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 24 Dec 2021 21:34:11 +0100 Subject: Fix zero-copy update to libkeccak_generalised_sum_fd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libkeccak_generalised_sum_fd.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libkeccak_generalised_sum_fd.c b/libkeccak_generalised_sum_fd.c index 78890b4..e86c459 100644 --- a/libkeccak_generalised_sum_fd.c +++ b/libkeccak_generalised_sum_fd.c @@ -1,5 +1,6 @@ /* See LICENSE file for copyright and license details. */ #include "common.h" +#include /** @@ -25,14 +26,16 @@ libkeccak_generalised_sum_fd(int fd, struct libkeccak_state *restrict state, con #endif size_t blksize = 4096; unsigned char *restrict chunk; - size_t chunksize = libkeccak_zerocopy_chunksize(state); - size_t extrasize = (strlen(suffix) + 2 + 7) >> 3; - size_t extrachunks = (extrasize + (chunksize - 1)) / chunksize; + size_t chunksize, extrasize, extrachunks; size_t chunks, chunkmod; if (libkeccak_state_initialise(state, spec) < 0) return -1; + chunksize = libkeccak_zerocopy_chunksize(state); + extrasize = ((suffix ? strlen(suffix) : 0) + 2 + 7) >> 3; + extrachunks = (extrasize + (chunksize - 1)) / chunksize; + #ifndef _WIN32 if (fstat(fd, &attr) == 0) if (attr.st_blksize > 0) -- cgit v1.2.3-70-g09d2