From dc0443270904bf623d5b4a8e7b9ed8467eb9c93c Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 6 Sep 2023 17:13:04 -0400 Subject: bfstd: Work around a FreeBSD-specific msan issue Link: https://github.com/llvm/llvm-project/issues/65532 --- src/bfstd.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'src/bfstd.c') diff --git a/src/bfstd.c b/src/bfstd.c index c858910..1a5a67d 100644 --- a/src/bfstd.c +++ b/src/bfstd.c @@ -5,6 +5,7 @@ #include "bit.h" #include "config.h" #include "diag.h" +#include "sanity.h" #include "thread.h" #include "xregex.h" #include @@ -590,11 +591,20 @@ static unsigned char ctype_cache[UCHAR_MAX + 1]; /** Initialize the ctype cache. */ static void char_cache_init(void) { +#if __FreeBSD__ && SANITIZE_MEMORY +// Work around https://github.com/llvm/llvm-project/issues/65532 +# define bfs_isprint (isprint) +# define bfs_isspace (isspace) +#else +# define bfs_isprint isprint +# define bfs_isspace isspace +#endif + for (size_t c = 0; c <= UCHAR_MAX; ++c) { - if (isprint(c)) { + if (bfs_isprint(c)) { ctype_cache[c] |= IS_PRINT; } - if (isspace(c)) { + if (bfs_isspace(c)) { ctype_cache[c] |= IS_SPACE; } } @@ -618,11 +628,20 @@ static bool xisprint(unsigned char c, enum wesc_flags flags) { /** Check if a wide character is printable. */ static bool xiswprint(wchar_t c, enum wesc_flags flags) { - if (iswprint(c)) { +#if __FreeBSD__ && SANITIZE_MEMORY +// Work around https://github.com/llvm/llvm-project/issues/65532 +# define bfs_iswprint (iswprint) +# define bfs_iswspace (iswspace) +#else +# define bfs_iswprint iswprint +# define bfs_iswspace iswspace +#endif + + if (bfs_iswprint(c)) { return true; } - if (!(flags & WESC_SHELL) && iswspace(c)) { + if (!(flags & WESC_SHELL) && bfs_iswspace(c)) { return true; } -- cgit v1.2.3