Skip to content

Commit 7f4427c

Browse files
committed
Fix ubsan false positive
1 parent f2b6c98 commit 7f4427c

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Zend/zend_portability.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,12 @@ extern "C++" {
515515
# undef HAVE_FUNC_ATTRIBUTE_IFUNC
516516
#endif
517517

518+
#if __has_feature(memory_sanitizer)
519+
# define MSAN_UNPOISON(value) __msan_unpoison(&(value), sizeof(value))
520+
#else
521+
# define MSAN_UNPOISON(value)
522+
#endif
523+
518524
/* Only use ifunc resolvers if we have __builtin_cpu_supports() and __builtin_cpu_init(),
519525
* otherwise the use of zend_cpu_supports() may not be safe inside ifunc resolvers. */
520526
#if defined(HAVE_FUNC_ATTRIBUTE_IFUNC) && defined(HAVE_FUNC_ATTRIBUTE_TARGET) && \

ext/standard/basic_functions.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,6 +1182,7 @@ PHP_FUNCTION(time_nanosleep)
11821182
RETURN_TRUE;
11831183
} else if (errno == EINTR) {
11841184
array_init(return_value);
1185+
MSAN_UNPOISON(php_rem);
11851186
add_assoc_long_ex(return_value, "seconds", sizeof("seconds")-1, php_rem.tv_sec);
11861187
add_assoc_long_ex(return_value, "nanoseconds", sizeof("nanoseconds")-1, php_rem.tv_nsec);
11871188
return;

0 commit comments

Comments
 (0)