From 2550f5ae126bf33148dabf30ae97b6d6d82e30a0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 28 Sep 2006 06:43:27 +0000 Subject: r18970: avoid strndup and strnlen on AIX. They are quite broken. See http://lists.samba.org/archive/samba-technical/2004-August/036915.html (This used to be commit c178c84f01166609e6bd3393d39fb0034130167b) --- source4/lib/replace/libreplace_cc.m4 | 2 ++ source4/lib/replace/replace.h | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 index b3b2b0d2bb..73ce01700e 100644 --- a/source4/lib/replace/libreplace_cc.m4 +++ b/source4/lib/replace/libreplace_cc.m4 @@ -66,6 +66,8 @@ case "$host_os" in fi ;; *aix*) + AC_DEFINE(BROKEN_STRNDUP, 1, [Whether strndup is broken]) + AC_DEFINE(BROKEN_STRNLEN, 1, [Whether strnlen is broken]) if test "${GCC}" != "yes"; then ## for funky AIX compiler using strncpy() CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000" diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 01f626390c..a6c7f3b9dd 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -121,12 +121,14 @@ size_t rep_strlcpy(char *d, const char *s, size_t bufsize); size_t rep_strlcat(char *d, const char *s, size_t bufsize); #endif -#ifndef HAVE_STRNDUP +#if (defined(BROKEN_STRNDUP) || !defined(HAVE_STRNDUP)) +#undef HAVE_STRNDUP #define strndup rep_strndup char *rep_strndup(const char *s, size_t n); #endif -#ifndef HAVE_STRNLEN +#if (defined(BROKEN_STRNLEN) || !defined(HAVE_STRNLEN)) +#undef HAVE_STRNLEN #define strnlen rep_strnlen size_t rep_strnlen(const char *s, size_t n); #endif -- cgit