From 66ff071274a74ff67d518d194a086e6772d89796 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 3 Feb 2022 22:58:29 +0100 Subject: Fix blksize adjustment when exceeding alloca limit in 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 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libkeccak_generalised_sum_fd.c b/libkeccak_generalised_sum_fd.c index e86c459..92a5c4c 100644 --- a/libkeccak_generalised_sum_fd.c +++ b/libkeccak_generalised_sum_fd.c @@ -53,8 +53,12 @@ libkeccak_generalised_sum_fd(int fd, struct libkeccak_state *restrict state, con blksize = (extrachunks + 1) * chunksize; #if ALLOCA_LIMIT > 0 - if (blksize > (size_t)ALLOCA_LIMIT) + if (blksize > (size_t)ALLOCA_LIMIT) { blksize = (size_t)ALLOCA_LIMIT; + blksize -= blksize % chunksize; + if (!blksize) + blksize = chunksize; + } # if defined(__clang__) /* We are using a limit so it's just like declaring an array * in a function, except we might use less of the stack. */ -- cgit v1.2.3-70-g09d2