From 71e574aa67c00ddefc9c59adb1f476af8697f640 Mon Sep 17 00:00:00 2001
From: MoustaphaSaad <moustapha.saad.abdelhamed@gmail.com>
Date: Mon, 10 Jun 2024 21:31:42 +0300
Subject: use compat implementations of strlcpy and strlcat

strlcpy and strlcat Emscripten implementations cause ASAN errors. This commit disables strlcpy and strlcat detection and uses the compat implementations instead.
---
 CMakeLists.txt | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 438e622..c496ad9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -220,14 +220,17 @@ if(HAVE_STRCASECMP)
 	add_definitions(-DHAVE_STRCASECMP)
 endif()
 
-check_function_exists(strlcat HAVE_STRLCAT)
-if(HAVE_STRLCAT)
-	add_definitions(-DHAVE_STRLCAT)
-endif()
+# Emscripten's strlcat and strlcpy triggers ASAN errors
+if(NOT EMSCRIPTEN)
+	check_function_exists(strlcat HAVE_STRLCAT)
+	if(HAVE_STRLCAT)
+		add_definitions(-DHAVE_STRLCAT)
+	endif()
 
-check_function_exists(strlcpy HAVE_STRLCPY)
-if(HAVE_STRLCPY)
-	add_definitions(-DHAVE_STRLCPY)
+	check_function_exists(strlcpy HAVE_STRLCPY)
+	if(HAVE_STRLCPY)
+		add_definitions(-DHAVE_STRLCPY)
+	endif()
 endif()
 
 check_function_exists(strndup HAVE_STRNDUP)
-- 
cgit v1.2.3-55-g6feb