mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Extract strlcpy and strlcmp to libtor-string
This commit is contained in:
@@ -4,3 +4,6 @@ lib/err/*.h
|
||||
lib/malloc/*.h
|
||||
lib/ctime/*.h
|
||||
lib/string/*.h
|
||||
|
||||
strlcat.c
|
||||
strlcpy.c
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
/* Copyright (c) 2003-2004, Roger Dingledine
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2018, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
#include "lib/string/compat_string.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
|
||||
@@ -0,0 +1,39 @@
|
||||
/* Copyright (c) 2003-2004, Roger Dingledine
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2018, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
#ifndef TOR_COMPAT_STRING_H
|
||||
#define TOR_COMPAT_STRING_H
|
||||
|
||||
#include "orconfig.h"
|
||||
#include "lib/cc/compat_compiler.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/* ===== 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
|
||||
|
||||
#endif
|
||||
@@ -7,6 +7,7 @@ endif
|
||||
|
||||
src_lib_libtor_string_a_SOURCES = \
|
||||
src/lib/string/compat_ctype.c \
|
||||
src/lib/string/compat_string.c \
|
||||
src/lib/string/util_string.c \
|
||||
src/lib/string/printf.c \
|
||||
src/lib/string/scanf.c
|
||||
@@ -18,6 +19,7 @@ src_lib_libtor_string_testing_a_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
|
||||
|
||||
noinst_HEADERS += \
|
||||
src/lib/string/compat_ctype.h \
|
||||
src/lib/string/compat_string.h \
|
||||
src/lib/string/util_string.h \
|
||||
src/lib/string/printf.h \
|
||||
src/lib/string/scanf.h
|
||||
|
||||
Reference in New Issue
Block a user