From 4c6bd9470c7a1625f2f114a816e539cfd779a544 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Tue, 16 Dec 2014 16:25:29 +0100 Subject: [PATCH] eliminated the need for strlcat in the library --- configure.in | 2 +- lib/util.c | 42 ------------------------------------------ lib/util.h | 5 ----- 3 files changed, 1 insertion(+), 48 deletions(-) diff --git a/configure.in b/configure.in index 959e07cd..e89835c1 100644 --- a/configure.in +++ b/configure.in @@ -204,7 +204,7 @@ AC_FUNC_STRFTIME AC_FUNC_ALLOCA AC_REPLACE_FUNCS(strdup strerror strcasecmp) AC_CHECK_FUNCS(flock fcntl uname gethostname sysinfo getdomainname) -AC_CHECK_FUNCS(stricmp random rand snprintf vsnprintf strlcpy strlcat) +AC_CHECK_FUNCS(stricmp random rand snprintf vsnprintf strlcpy) if test "$ac_cv_func_uname" = 'yes' && test "$cross_compiling" = 'no' then diff --git a/lib/util.c b/lib/util.c index 3acbc772..0cd4bff6 100644 --- a/lib/util.c +++ b/lib/util.c @@ -347,48 +347,6 @@ rc_getctime(void) return timev.tv_sec + ((double)timev.tv_usec) / 1000000.0; } -#ifndef HAVE_STRLCAT -/* - * Replacement for a missing strlcat. - * - * Provides the same functionality as the *BSD function strlcat, originally - * developed by Todd Miller and Theo de Raadt. strlcat works similarly to - * strncat, except simpler. The result is always nul-terminated even if the - * source string is longer than the space remaining in the destination string, - * and the total space required is returned. The third argument is the total - * space available in the destination buffer, not just the amount of space - * remaining. - * - * The canonical version of this file is maintained in the rra-c-util package, - * which can be found at . - * - * Written by Russ Allbery - * - * The authors hereby relinquish any claim to any copyright that they may have - * in this work, whether granted under contract or by operation of law or - * international treaty, and hereby commit to the public, at large, that they - * shall not, at any time in the future, seek to enforce any copyright in this - * work against any person or entity, or prevent any person or entity from - * copying, publishing, distributing or creating derivative works of this - * work. - */ - -size_t -rc_strlcat(char *dst, const char *src, size_t size) -{ - size_t used, length, copy; - - used = strlen(dst); - length = strlen(src); - if (size > 0 && used < size - 1) { - copy = (length >= size - used) ? size - used - 1 : length; - memcpy(dst + used, src, copy); - dst[used + copy] = '\0'; - } - return used + length; -} -#endif - /* * Copyright (c) 1998 Todd C. Miller * diff --git a/lib/util.h b/lib/util.h index 060ab0b6..fb9655ae 100644 --- a/lib/util.h +++ b/lib/util.h @@ -15,10 +15,5 @@ size_t rc_strlcpy(char *dst, char const *src, size_t siz); # define strlcpy rc_strlcpy #endif -#ifndef HAVE_STRLCAT -size_t rc_strlcat(char *dst, const char *src, size_t size); -# define strlcat rc_strlcat -#endif - #endif /* UTIL_H */