From 90a09df5ba7b3e55ea388a4cc9b92161442bb380 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 22 Jun 2018 11:18:19 -0400 Subject: Extract strlcpy and strlcmp to libtor-string --- src/common/.may_include | 2 -- src/common/compat.c | 8 -------- src/common/compat.h | 26 +------------------------- 3 files changed, 1 insertion(+), 35 deletions(-) (limited to 'src/common') diff --git a/src/common/.may_include b/src/common/.may_include index d2a3d2fff3..484b57e100 100644 --- a/src/common/.may_include +++ b/src/common/.may_include @@ -8,7 +8,5 @@ linux_syscalls.inc micro-revision.i siphash.h src/ext/timeouts/timeout.c -strlcat.c -strlcpy.c tor_queue.h tor_readpassphrase.h diff --git a/src/common/compat.c b/src/common/compat.c index 351fa05634..1dcd065810 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -131,14 +131,6 @@ SecureZeroMemory(PVOID ptr, SIZE_T cnt) #include "common/address.h" #include "common/sandbox.h" -/* Inline the strl functions if the platform doesn't have them. */ -#ifndef HAVE_STRLCPY -#include "strlcpy.c" -#endif -#ifndef HAVE_STRLCAT -#include "strlcat.c" -#endif - /* When set_max_file_descriptors() is called, update this with the max file * descriptor value so we can use it to check the limit when opening a new * socket. Default value is what Debian sets as the default hard limit. */ diff --git a/src/common/compat.h b/src/common/compat.h index 21fd0211a3..605438cc62 100644 --- a/src/common/compat.h +++ b/src/common/compat.h @@ -48,6 +48,7 @@ #include "lib/cc/compat_compiler.h" #include "common/compat_time.h" #include "lib/string/compat_ctype.h" +#include "lib/string/compat_string.h" #include "lib/string/printf.h" #include @@ -55,31 +56,6 @@ /* ===== Compiler compatibility */ -/* ===== String compatibility */ -#ifdef _WIN32 -/* Windows names string functions differently from most other platforms. */ -#define strncasecmp _strnicmp -#define strcasecmp _stricmp -#endif - -#if defined __APPLE__ -/* On OSX 10.9 and later, the overlap-checking code for strlcat would - * appear to have a severe bug that can sometimes cause aborts in Tor. - * Instead, use the non-checking variants. This is sad. - * - * See https://trac.torproject.org/projects/tor/ticket/15205 - */ -#undef strlcat -#undef strlcpy -#endif /* defined __APPLE__ */ - -#ifndef HAVE_STRLCAT -size_t strlcat(char *dst, const char *src, size_t siz) ATTR_NONNULL((1,2)); -#endif -#ifndef HAVE_STRLCPY -size_t strlcpy(char *dst, const char *src, size_t siz) ATTR_NONNULL((1,2)); -#endif - /** Represents an mmaped file. Allocated via tor_mmap_file; freed with * tor_munmap_file. */ typedef struct tor_mmap_t { -- cgit v1.2.3-54-g00ecf