summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sanitizer_common')
-rw-r--r--lib/sanitizer_common/sanitizer_common_interceptors.inc20
-rw-r--r--lib/sanitizer_common/sanitizer_platform_interceptors.h3
-rw-r--r--lib/sanitizer_common/sanitizer_platform_limits_freebsd.cc3
-rw-r--r--lib/sanitizer_common/sanitizer_platform_limits_freebsd.h2
4 files changed, 21 insertions, 7 deletions
diff --git a/lib/sanitizer_common/sanitizer_common_interceptors.inc b/lib/sanitizer_common/sanitizer_common_interceptors.inc
index ff378e1e9..1f446feba 100644
--- a/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -7421,6 +7421,16 @@ INTERCEPTOR(void, regfree, const void *preg) {
COMMON_INTERCEPTOR_READ_RANGE(ctx, preg, struct_regex_sz);
REAL(regfree)(preg);
}
+#define INIT_REGEX \
+ COMMON_INTERCEPT_FUNCTION(regcomp); \
+ COMMON_INTERCEPT_FUNCTION(regexec); \
+ COMMON_INTERCEPT_FUNCTION(regerror); \
+ COMMON_INTERCEPT_FUNCTION(regfree);
+#else
+#define INIT_REGEX
+#endif
+
+#if SANITIZER_INTERCEPT_REGEXSUB
INTERCEPTOR(SSIZE_T, regnsub, char *buf, SIZE_T bufsiz, const char *sub,
const struct __sanitizer_regmatch *rm, const char *str) {
void *ctx;
@@ -7455,15 +7465,12 @@ INTERCEPTOR(SSIZE_T, regasub, char **buf, const char *sub,
}
return res;
}
-#define INIT_REGEX \
- COMMON_INTERCEPT_FUNCTION(regcomp); \
- COMMON_INTERCEPT_FUNCTION(regexec); \
- COMMON_INTERCEPT_FUNCTION(regerror); \
- COMMON_INTERCEPT_FUNCTION(regfree); \
+
+#define INIT_REGEXSUB \
COMMON_INTERCEPT_FUNCTION(regnsub); \
COMMON_INTERCEPT_FUNCTION(regasub);
#else
-#define INIT_REGEX
+#define INIT_REGEXSUB
#endif
#if SANITIZER_INTERCEPT_FTS
@@ -9297,6 +9304,7 @@ static void InitializeCommonInterceptors() {
INIT_SETVBUF;
INIT_GETVFSSTAT;
INIT_REGEX;
+ INIT_REGEXSUB;
INIT_FTS;
INIT_SYSCTL;
INIT_ASYSCTL;
diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h
index a914d20a0..f3a320732 100644
--- a/lib/sanitizer_common/sanitizer_platform_interceptors.h
+++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h
@@ -522,7 +522,8 @@
#define SANITIZER_INTERCEPT_GETMNTINFO (SI_NETBSD || SI_FREEBSD || SI_MAC)
#define SANITIZER_INTERCEPT_MI_VECTOR_HASH SI_NETBSD
#define SANITIZER_INTERCEPT_GETVFSSTAT SI_NETBSD
-#define SANITIZER_INTERCEPT_REGEX SI_NETBSD
+#define SANITIZER_INTERCEPT_REGEX (SI_NETBSD || SI_FREEBSD)
+#define SANITIZER_INTERCEPT_REGEXSUB SI_NETBSD
#define SANITIZER_INTERCEPT_FTS SI_NETBSD
#define SANITIZER_INTERCEPT_SYSCTL (SI_NETBSD || SI_FREEBSD || SI_MAC)
#define SANITIZER_INTERCEPT_ASYSCTL SI_NETBSD
diff --git a/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cc b/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cc
index 3eaa695ae..8bca8f445 100644
--- a/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cc
+++ b/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cc
@@ -25,6 +25,7 @@
#include <poll.h>
#include <pthread.h>
#include <pwd.h>
+#include <regex.h>
#include <signal.h>
#include <stddef.h>
#include <sys/mman.h>
@@ -125,6 +126,8 @@ namespace __sanitizer {
unsigned struct_statvfs_sz = sizeof(struct statvfs);
unsigned struct_shminfo_sz = sizeof(struct shminfo);
unsigned struct_shm_info_sz = sizeof(struct shm_info);
+ unsigned struct_regmatch_sz = sizeof(regmatch_t);
+ unsigned struct_regex_sz = sizeof(regex_t);
const uptr sig_ign = (uptr)SIG_IGN;
const uptr sig_dfl = (uptr)SIG_DFL;
diff --git a/lib/sanitizer_common/sanitizer_platform_limits_freebsd.h b/lib/sanitizer_common/sanitizer_platform_limits_freebsd.h
index b212c005c..d383bceb0 100644
--- a/lib/sanitizer_common/sanitizer_platform_limits_freebsd.h
+++ b/lib/sanitizer_common/sanitizer_platform_limits_freebsd.h
@@ -62,6 +62,8 @@ namespace __sanitizer {
extern unsigned struct_rlimit_sz;
extern unsigned struct_utimbuf_sz;
extern unsigned struct_timespec_sz;
+ extern unsigned struct_regmatch_sz;
+ extern unsigned struct_regex_sz;
extern const int unvis_valid;
extern const int unvis_validpush;