From: Douglas Bagnall Date: Fri, 28 Jul 2023 03:36:21 +0000 (+1200) Subject: lib/replace: fix strlcat/strlcpy compile for Honggfuzz X-Git-Tag: tevent-0.16.0~1084 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=269738d6ce42a2e4979bfca33328fbf0bf0e6d10;p=thirdparty%2Fsamba.git lib/replace: fix strlcat/strlcpy compile for Honggfuzz Otherwise we getthis kind of thing: ../../lib/replace/replace.c:837:3: error: implicit declaration of function 'strlcpy' is invalid in C99 [-Werror,-Wimplicit-function-declaration] strlcpy(buf, s, buflen); ../../third_party/heimdal/lib/roken/getarg.c:288:6: error: implicit declaration of function 'strlcat' is invalid in C99 [-Werror,-Wimplicit-function-declaration] strlcat(buf, "]", sizeof(buf)); because we found the symbol names in libc, but didn't check that the functions are declared in . We already include whenever we have it. Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett Autobuild-User(master): Andrew Bartlett Autobuild-Date(master): Tue Aug 8 05:35:08 UTC 2023 on atb-devel-224 --- diff --git a/lib/replace/wscript b/lib/replace/wscript index 37d77593900..77e655bb68b 100644 --- a/lib/replace/wscript +++ b/lib/replace/wscript @@ -448,6 +448,17 @@ def configure(conf): if conf.CHECK_FUNCS_IN('strlcpy strlcat', 'bsd', headers='bsd/string.h', checklibc=True): strlcpy_in_bsd = True + elif conf.env.enable_fuzzing: + # Just to complicate it more, some versions of Honggfuzz have + # got strlcpy and strlcat in libc, but not in + # (unless it is there coincidentally, on a BSD). Therefore we + # can't use CHECK_FUNCS alone to decide whether to add the + # headers to replace.h. + # + # As this is only known to happen on a fuzzing compiler, we'll + # skip the check when not in fuzzing mode. + conf.CHECK_HEADERS('bsd/string.h') + if not conf.CHECK_FUNCS('getpeereid'): conf.CHECK_FUNCS_IN('getpeereid', 'bsd', headers='sys/types.h bsd/unistd.h') if not conf.CHECK_FUNCS_IN('setproctitle', 'setproctitle', headers='setproctitle.h'):