compat_string.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* Copyright (c) 2003-2004, Roger Dingledine
  2. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  3. * Copyright (c) 2007-2018, The Tor Project, Inc. */
  4. /* See LICENSE for licensing information */
  5. #ifndef TOR_COMPAT_STRING_H
  6. #define TOR_COMPAT_STRING_H
  7. #include "orconfig.h"
  8. #include "lib/cc/compat_compiler.h"
  9. #include <stddef.h>
  10. /* ===== String compatibility */
  11. #ifdef _WIN32
  12. /* Windows names string functions differently from most other platforms. */
  13. #define strncasecmp _strnicmp
  14. #define strcasecmp _stricmp
  15. #endif
  16. #if defined __APPLE__
  17. /* On OSX 10.9 and later, the overlap-checking code for strlcat would
  18. * appear to have a severe bug that can sometimes cause aborts in Tor.
  19. * Instead, use the non-checking variants. This is sad.
  20. *
  21. * See https://trac.torproject.org/projects/tor/ticket/15205
  22. */
  23. #undef strlcat
  24. #undef strlcpy
  25. #endif /* defined __APPLE__ */
  26. #ifndef HAVE_STRLCAT
  27. size_t strlcat(char *dst, const char *src, size_t siz) ATTR_NONNULL((1,2));
  28. #endif
  29. #ifndef HAVE_STRLCPY
  30. size_t strlcpy(char *dst, const char *src, size_t siz) ATTR_NONNULL((1,2));
  31. #endif
  32. #endif