|
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;
|
@@ -508,3 +512,27 @@ ZEND_API zend_string *zend_string_concat3(
|
508 | 512 |
|
509 | 513 | return res;
|
510 | 514 | }
|
| 515 | + |
| 516 | +/* strlcpy and strlcat are not intercepted by msan, so we need to do it ourselves. */ |
| 517 | +#if __has_feature(memory_sanitizer) |
| 518 | +static size_t (*libc_strlcpy)(char *__restrict, const char *__restrict, size_t); |
| 519 | +size_t strlcpy(char *__restrict dest, const char *__restrict src, size_t n) |
| 520 | +{ |
| 521 | + if (!libc_strlcpy) { |
| 522 | + libc_strlcpy = dlsym(RTLD_NEXT, "strlcpy"); |
| 523 | + } |
| 524 | + size_t result = libc_strlcpy(dest, src, n); |
| 525 | + __msan_unpoison_string(dest); |
| 526 | + return result; |
| 527 | +} |
| 528 | +static size_t (*libc_strlcat)(char *__restrict, const char *__restrict, size_t); |
| 529 | +size_t strlcat (char *__restrict dest, const char *restrict src, size_t n) |
| 530 | +{ |
| 531 | + if (!libc_strlcat) { |
| 532 | + libc_strlcat = dlsym(RTLD_NEXT, "strlcat"); |
| 533 | + } |
| 534 | + size_t result = libc_strlcat(dest, src, n); |
| 535 | + __msan_unpoison_string(dest); |
| 536 | + return result; |
| 537 | +} |
| 538 | +#endif |
0 commit comments