|
23 | 23 | # include "valgrind/callgrind.h"
|
24 | 24 | #endif
|
25 | 25 |
|
| 26 | +#if __has_feature(memory_sanitizer) |
| 27 | +# include <sanitizer/msan_interface.h> |
| 28 | +#endif |
| 29 | + |
26 | 30 | ZEND_API zend_new_interned_string_func_t zend_new_interned_string;
|
27 | 31 | ZEND_API zend_string_init_interned_func_t zend_string_init_interned;
|
28 | 32 | ZEND_API zend_string_init_existing_interned_func_t zend_string_init_existing_interned;
|
@@ -490,3 +494,27 @@ ZEND_API zend_string *zend_string_concat3(
|
490 | 494 |
|
491 | 495 | return res;
|
492 | 496 | }
|
| 497 | + |
| 498 | +/* strlcpy and strlcat are not intercepted by msan, so we need to do it ourselves. */ |
| 499 | +#if __has_feature(memory_sanitizer) |
| 500 | +static size_t (*libc_strlcpy)(char *__restrict, const char *__restrict, size_t); |
| 501 | +size_t strlcpy(char *__restrict dest, const char *__restrict src, size_t n) |
| 502 | +{ |
| 503 | + if (!libc_strlcpy) { |
| 504 | + libc_strlcpy = dlsym(RTLD_NEXT, "strlcpy"); |
| 505 | + } |
| 506 | + size_t result = libc_strlcpy(dest, src, n); |
| 507 | + __msan_unpoison_string(dest); |
| 508 | + return result; |
| 509 | +} |
| 510 | +static size_t (*libc_strlcat)(char *__restrict, const char *__restrict, size_t); |
| 511 | +size_t strlcat (char *__restrict dest, const char *restrict src, size_t n) |
| 512 | +{ |
| 513 | + if (!libc_strlcat) { |
| 514 | + libc_strlcat = dlsym(RTLD_NEXT, "strlcat"); |
| 515 | + } |
| 516 | + size_t result = libc_strlcat(dest, src, n); |
| 517 | + __msan_unpoison_string(dest); |
| 518 | + return result; |
| 519 | +} |
| 520 | +#endif |
0 commit comments