From 01f426484406816139abb58943636bf852a0aa79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20R=C3=B6hling?= Date: Mon, 7 Aug 2023 10:01:07 +0200 Subject: [PATCH] Fix alloca usage on FreeBSD --- CMakeLists.txt | 4 +++- src/srs2.c | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d79dacd..4f733c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -289,8 +289,10 @@ if(WITH_SQLITE) SQLITE_OMIT_DEPRECATED SQLITE_OMIT_PROGRESS_CALLBACK SQLITE_OMIT_SHARED_CACHE - SQLITE_USE_ALLOCA ) + if(HAVE_ALLOCA_H) + target_compile_definitions(sqlite3 PRIVATE SQLITE_USE_ALLOCA) + endif() if(WITH_MILTER AND TARGET Threads::Threads) target_link_libraries(sqlite3 PRIVATE Threads::Threads) endif() diff --git a/src/srs2.c b/src/srs2.c index 9397d2e..606e216 100644 --- a/src/srs2.c +++ b/src/srs2.c @@ -20,8 +20,6 @@ #include #include -#include /* memcpy, strcpy, memset */ -#include #ifdef HAVE_ALLOCA_H # include #endif @@ -285,7 +283,11 @@ static void srs_hash_create_v(srs_t* srs, int idx, char* buf, int nargs, { data = va_arg(ap, char*); len = strlen(data); +#ifndef HAVE_ALLOCA_H + lcdata = malloc(len + 1); +#else lcdata = alloca(len + 1); +#endif for (j = 0; j < len; j++) { if (isupper(data[j])) @@ -297,6 +299,9 @@ static void srs_hash_create_v(srs_t* srs, int idx, char* buf, int nargs, HMAC_Update(&ctx, lcdata, len); #else srs_hmac_update(&ctx, lcdata, len); +#endif +#ifndef HAVE_ALLOCA_H + free(lcdata); #endif }