[libfko] Candidate build fix for Mac OS X 10.9 (closes #108)

Nikolay Kolev reported a build issue on Mac OS X 10.9 (Mavericks) where fwknop
copies of strlcpy() and strlcat() functions were conflicting with those that ship
with OS X 10.9.

The solution was to add a configure.ac check for strlcat() and strlcpy() and
wrap "#if !HAVE_..." checks around those functions.

A portion of the build errors looked like this:

/Applications/Xcode.app/Contents/Developer/usr/bin/make  all-recursive
Making all in lib
/bin/sh ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I..   -I ../common   -g -O2 -Wall -Wformat -Wformat-security -fstack-protector-all -fstack-protector -fPIE -D_FORTIFY_SOURCE=2 -MT base64.lo -MD -MP -MF .deps/base64.Tpo -c -o base64.lo base64.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I.. -I ../common -g -O2 -Wall -Wformat -Wformat-security -fstack-protector-all -fstack-protector -D_FORTIFY_SOURCE=2 -MT base64.lo -MD -MP -MF .deps/base64.Tpo -c base64.c  -fno-common -DPIC -o .libs/base64.o
In file included from base64.c:34:
In file included from ./fko_common.h:149:
./fko_util.h:56:9: error: expected parameter declarator
size_t  strlcat(char *dst, const char *src, size_t siz);
        ^
/usr/include/secure/_string.h:111:44: note: expanded from macro 'strlcat'
  __builtin___strlcat_chk (dest, src, len, __darwin_obsz (dest))
                                           ^
/usr/include/secure/_common.h:39:62: note: expanded from macro '__darwin_obsz'
 #define __darwin_obsz(object) __builtin_object_size (object, _USE_FORTIFY_LEVEL > 1 ? 1 : 0)
                                                             ^
This commit is contained in:
Michael Rash 2013-11-12 21:36:14 -05:00
parent 5cfbcce7d3
commit 23ef1d4e59
5 changed files with 13 additions and 1 deletions

View File

@ -2,6 +2,9 @@ fwknop-2.5.2 (//2013):
- (Radostan Riedel) Added an AppArmor policy that is known to work on
Debian and Ubuntu systems. The policy file is available in
extras/apparmor.
- [libfko] Nikolay Kolev reported a build issue with Mac OS X Mavericks
where local fwknop copies of strlcat() and strlcpy() were conflicting
with those that already ship with OS X 10.9. Closes #108 on github.
- [libfko] (Franck Joncourt) Consolidated FKO context dumping function into
lib/fko_util.c. In addition to adding a shared utility function for
printing an FKO context, this change also makes the FKO context output

View File

@ -257,7 +257,7 @@ AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_FUNC_STAT
AC_CHECK_FUNCS([bzero gettimeofday memmove memset socket strchr strcspn strdup strncasecmp strndup strrchr strspn strnlen stat chmod chown])
AC_CHECK_FUNCS([bzero gettimeofday memmove memset socket strchr strcspn strdup strncasecmp strndup strrchr strspn strnlen stat chmod chown strlcat strlcpy])
AC_SEARCH_LIBS([socket], [socket])
AC_SEARCH_LIBS([inet_addr], [nsl])

View File

@ -53,8 +53,13 @@ int zero_buf(char *buf, int len);
const char * enc_type_inttostr(const int type);
const char * msg_type_inttostr(const int type);
#if !HAVE_STRLCAT
size_t strlcat(char *dst, const char *src, size_t siz);
#endif
#if !HAVE_STRLCPY
size_t strlcpy(char *dst, const char *src, size_t siz);
#endif
#if defined(WIN32) || !defined(HAVE_STRNDUP)
char * strndup( const char * s, size_t len );

View File

@ -34,6 +34,7 @@
*/
#include "fko_common.h"
#if !HAVE_STRLCAT
/*
* Appends src to string dst of size siz (unlike strncat, siz is the
* full size of dst, not space left). At most siz-1 characters
@ -68,5 +69,6 @@ strlcat(char *dst, const char *src, size_t siz)
return(dlen + (s - src)); /* count does not include NUL */
}
#endif
/***EOF***/

View File

@ -34,6 +34,7 @@
*/
#include "fko_common.h"
#if !HAVE_STRLCPY
/*
* Copy src to string dst of size siz. At most siz-1 characters
* will be copied. Always NUL terminates (unless siz == 0).
@ -64,5 +65,6 @@ strlcpy(char *dst, const char *src, size_t siz)
return(s - src - 1); /* count does not include NUL */
}
#endif
/***EOF***/