>From 5169e5b9ad6d813d6026a3f268b335438cd1881b Mon Sep 17 00:00:00 2001 From: Peter Bex Date: Thu, 6 Feb 2014 09:56:48 +0100 Subject: [PATCH 1/2] Prevent problems when the host system does provide strlcpy/strlcat. Defining strlcat/strlcopy causes trouble if HAVE_STRLCAT/HAVE_STRLCPY is not set and the host system does offer these functions. This could also happen on systems that don't offer these functions but bsd/string.h is being included by user code on Linux, for example. Instead of defining strlcat and defining C_strlcat to point to that, we define the replacement function directly under the name C_strlcat. On systems which do have strlcat, we define C_strlcat as an alias of strlcat. --- chicken.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/chicken.h b/chicken.h index 6b8fc6a..e848e6e 100644 --- a/chicken.h +++ b/chicken.h @@ -923,12 +923,10 @@ DECL_C_PROC_p0 (128, 1,0,0,0,0,0,0,0) # define C_memcpy memcpy # define C_memcmp memcmp -# define C_strlcpy strlcpy # define C_strncpy strncpy # define C_strcmp strcmp # define C_strncmp strncmp # define C_strlen strlen -# define C_strlcat strlcat # define C_memset memset # define C_memmove memmove # define C_strncasecmp strncasecmp @@ -3055,8 +3053,10 @@ C_path_to_executable(C_char *fname) #endif /* These strl* functions are based on public domain code by C.B. Falconer */ -#ifndef HAVE_STRLCPY -C_inline size_t strlcpy(char *dst, const char *src, size_t sz) +#ifdef HAVE_STRLCPY +# define C_strlcpy strlcpy +#else +C_inline size_t C_strlcpy(char *dst, const char *src, size_t sz) { const char *start = src; @@ -3074,7 +3074,9 @@ C_inline size_t strlcpy(char *dst, const char *src, size_t sz) #endif #ifndef HAVE_STRLCAT -C_inline size_t strlcat(char *dst, const char *src, size_t sz) +# define C_strlcat strlcat +#else +C_inline size_t C_strlcat(char *dst, const char *src, size_t sz) { char *start = dst; -- 1.8.2.3