0003-Prefix-some-compat-symbols-with-libressl_.patch 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. From 0a446e81ed77c20aa87563d45ef0ef8f5fa283d8 Mon Sep 17 00:00:00 2001
  2. From: Theo Buehler <tb@openbsd.org>
  3. Date: Sat, 18 Nov 2023 10:53:09 +0100
  4. Subject: [PATCH] Prefix some compat symbols with libressl_
  5. See #928. This isn't a full fix, but should remove much of the friction
  6. already.
  7. Upstream: https://github.com/libressl/portable/pull/961/commits/0a446e81ed77c20aa87563d45ef0ef8f5fa283d8
  8. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  9. ---
  10. include/compat/stdio.h | 2 ++
  11. include/compat/stdlib.h | 10 ++++++++++
  12. include/compat/string.h | 11 +++++++++++
  13. 3 files changed, 23 insertions(+)
  14. diff --git a/include/compat/stdio.h b/include/compat/stdio.h
  15. index d5725c9ac9..4ddd63aee1 100644
  16. --- a/include/compat/stdio.h
  17. +++ b/include/compat/stdio.h
  18. @@ -20,7 +20,9 @@
  19. #ifndef HAVE_ASPRINTF
  20. #include <stdarg.h>
  21. +#define vasprintf libressl_vasprintf
  22. int vasprintf(char **str, const char *fmt, va_list ap);
  23. +#define asprintf libressl_asprintf
  24. int asprintf(char **str, const char *fmt, ...);
  25. #endif
  26. diff --git a/include/compat/stdlib.h b/include/compat/stdlib.h
  27. index 2eaea244c0..76dc07c35a 100644
  28. --- a/include/compat/stdlib.h
  29. +++ b/include/compat/stdlib.h
  30. @@ -20,26 +20,36 @@
  31. #include <stdint.h>
  32. #ifndef HAVE_ARC4RANDOM_BUF
  33. +#define arc4random libressl_arc4random
  34. uint32_t arc4random(void);
  35. +#define arc4random_buf libressl_arc4random_buf
  36. void arc4random_buf(void *_buf, size_t n);
  37. +#define arc4random_uniform libressl_arc4random_uniform
  38. uint32_t arc4random_uniform(uint32_t upper_bound);
  39. #endif
  40. #ifndef HAVE_FREEZERO
  41. +#define freezero libressl_freezero
  42. void freezero(void *ptr, size_t sz);
  43. #endif
  44. #ifndef HAVE_GETPROGNAME
  45. +#define getprogname libressl_getprogname
  46. const char * getprogname(void);
  47. #endif
  48. +#ifndef HAVE_REALLOCARRAY
  49. +#define reallocarray libressl_reallocarray
  50. void *reallocarray(void *, size_t, size_t);
  51. +#endif
  52. #ifndef HAVE_RECALLOCARRAY
  53. +#define recallocarray libressl_recallocarray
  54. void *recallocarray(void *, size_t, size_t, size_t);
  55. #endif
  56. #ifndef HAVE_STRTONUM
  57. +#define strtonum libressl_strtonum
  58. long long strtonum(const char *nptr, long long minval,
  59. long long maxval, const char **errstr);
  60. #endif
  61. diff --git a/include/compat/string.h b/include/compat/string.h
  62. index 4bf7519b5b..6a82793f62 100644
  63. --- a/include/compat/string.h
  64. +++ b/include/compat/string.h
  65. @@ -27,43 +27,54 @@
  66. #endif
  67. #ifndef HAVE_STRCASECMP
  68. +#define strcasecmp libressl_strcasecmp
  69. int strcasecmp(const char *s1, const char *s2);
  70. +#define strncasecmp libressl_strncasecmp
  71. int strncasecmp(const char *s1, const char *s2, size_t len);
  72. #endif
  73. #ifndef HAVE_STRLCPY
  74. +#define strlcpy libressl_strlcpy
  75. size_t strlcpy(char *dst, const char *src, size_t siz);
  76. #endif
  77. #ifndef HAVE_STRLCAT
  78. +#define strlcat libressl_strlcat
  79. size_t strlcat(char *dst, const char *src, size_t siz);
  80. #endif
  81. #ifndef HAVE_STRNDUP
  82. +#define strndup libressl_strndup
  83. char * strndup(const char *str, size_t maxlen);
  84. /* the only user of strnlen is strndup, so only build it if needed */
  85. #ifndef HAVE_STRNLEN
  86. +#define strnlen libressl_strnlen
  87. size_t strnlen(const char *str, size_t maxlen);
  88. #endif
  89. #endif
  90. #ifndef HAVE_STRSEP
  91. +#define strsep libressl_strsep
  92. char *strsep(char **stringp, const char *delim);
  93. #endif
  94. #ifndef HAVE_EXPLICIT_BZERO
  95. +#define explicit_bzero libressl_explicit_bzero
  96. void explicit_bzero(void *, size_t);
  97. #endif
  98. #ifndef HAVE_TIMINGSAFE_BCMP
  99. +#define timingsafe_bcmp libressl_timingsafe_bcmp
  100. int timingsafe_bcmp(const void *b1, const void *b2, size_t n);
  101. #endif
  102. #ifndef HAVE_TIMINGSAFE_MEMCMP
  103. +#define timingsafe_memcmp libressl_timingsafe_memcmp
  104. int timingsafe_memcmp(const void *b1, const void *b2, size_t len);
  105. #endif
  106. #ifndef HAVE_MEMMEM
  107. +#define memmem libressl_memmem
  108. void * memmem(const void *big, size_t big_len, const void *little,
  109. size_t little_len);
  110. #endif