Skip to content

Commit a5ccd01

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 a5ccd01

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Zend/zend_string.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,9 @@ ZEND_API zend_string *zend_string_concat3(
502502

503503
/* strlcpy and strlcat are not intercepted by msan, so we need to do it ourselves. */
504504
#if __has_feature(memory_sanitizer)
505+
/* apply a simple heuristic to tell if the platform needs it,
506+
* see https://github.com/php/php-src/issues/20002 */
507+
#if !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)