Skip to content

Commit f88b4d7

Browse files
committed
Fix GH-20002: build on BSD with MSAN
The #if to have instrumented versions of strlcpy and strlcat was too inclusive, and defined them even on *BSD that indeed have those already defined, resulting in "duplicate symbol" at linking.
1 parent ba8472f commit f88b4d7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Zend/zend_string.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,11 @@ ZEND_API zend_string *zend_string_concat3(
500500
return res;
501501
}
502502

503-
/* strlcpy and strlcat are not intercepted by msan, so we need to do it ourselves. */
504-
#if __has_feature(memory_sanitizer)
503+
/* strlcpy and strlcat are not always intercepted by msan, so we need to do it
504+
* ourselves.
505+
* Apply a simple heuristic to tell if the platform needs it,
506+
* see https://github.com/php/php-src/issues/20002 */
507+
#if __has_feature(memory_sanitizer) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__APPLE__)
505508
static size_t (*libc_strlcpy)(char *__restrict, const char *__restrict, size_t);
506509
size_t strlcpy(char *__restrict dest, const char *__restrict src, size_t n)
507510
{
@@ -523,3 +526,4 @@ size_t strlcat (char *__restrict dest, const char *restrict src, size_t n)
523526
return result;
524527
}
525528
#endif
529+
#endif

0 commit comments

Comments
 (0)