]> granicus.if.org Git - php/commitdiff
Msan: Unpoison getrandom() syscall result
authorNikita Popov <nikita.ppv@gmail.com>
Mon, 1 Jul 2019 08:37:34 +0000 (10:37 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 1 Jul 2019 09:14:17 +0000 (11:14 +0200)
ext/standard/random.c

index f6568a658fd8e244a3e8bcf54a0cee28934baa37..82eee863e7a975aa6f46136998c72b287f9b72a1 100644 (file)
 # endif
 #endif
 
+#if __has_feature(memory_sanitizer)
+# include <sanitizer/msan_interface.h>
+#endif
+
 #ifdef ZTS
 int random_globals_id;
 #else
@@ -133,6 +137,10 @@ PHPAPI int php_random_bytes(void *bytes, size_t size, zend_bool should_throw)
                        }
                }
 
+#if __has_feature(memory_sanitizer)
+               /* MSan does not instrument manual syscall invocations. */
+               __msan_unpoison(bytes + read_bytes, n);
+#endif
                read_bytes += (size_t) n;
        }
 #endif