Skip to content

Commit 26ca363

Browse files
outtersgiluuu1994
authored andcommitted
Fix broken build on *BSD with MSAN
The #if to declare instrumented versions of strlcpy and strlcat was too inclusive on *BSD systems where Clang already provides instrumented strong symbols, resulting in "duplicate symbol" at link-time. Fix GH-20002 Closes GH-20032
1 parent 0ffa337 commit 26ca363

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ PHP NEWS
1414
array). (ilutov)
1515
. Fixed bug GH-19480 (error_log php.ini cannot be unset when open_basedir is
1616
configured). (nielsdos)
17+
. Fixed bug GH-20002 (Broken build on *BSD with MSAN). (outtersg)
1718

1819
- Curl:
1920
. Fix cloning of CURLOPT_POSTFIELDS when using the clone operator instead

Zend/zend_string.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,10 @@ ZEND_API zend_string *zend_string_concat3(
505505
return res;
506506
}
507507

508-
/* strlcpy and strlcat are not intercepted by msan, so we need to do it ourselves. */
509-
#if __has_feature(memory_sanitizer)
508+
/* strlcpy and strlcat are not always intercepted by msan, so we need to do it
509+
* ourselves. Apply a simple heuristic to determine the platforms that need it.
510+
* See https://github.com/php/php-src/issues/20002. */
511+
#if __has_feature(memory_sanitizer) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__APPLE__)
510512
static size_t (*libc_strlcpy)(char *__restrict, const char *__restrict, size_t);
511513
size_t strlcpy(char *__restrict dest, const char *__restrict src, size_t n)
512514
{

0 commit comments

Comments
 (0)