From 6bf61373084090f528a10b798960a4bb7e6802bb Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Wed, 5 Feb 2025 18:20:32 +0000 Subject: [PATCH] Auto-generate files after cl/723555860 --- php/ext/google/protobuf/php-upb.c | 11 ++++++++--- ruby/ext/google/protobuf_c/ruby-upb.c | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/php/ext/google/protobuf/php-upb.c b/php/ext/google/protobuf/php-upb.c index cf3afb14b7..0b2f4abfd8 100644 --- a/php/ext/google/protobuf/php-upb.c +++ b/php/ext/google/protobuf/php-upb.c @@ -11996,9 +11996,14 @@ uint32_t _upb_Hash(const void* p, size_t n, uint64_t seed) { return Wyhash(p, n, seed, kWyhashSalt); } -// Returns a seed for upb's hash function. For now this is just a hard-coded -// constant, but we are going to randomize it soon. -static uint64_t _upb_Seed(void) { return 0x69835f69597ec1cc; } +static const void* const _upb_seed; + +// Returns a random seed for upb's hash function. This does not provide +// high-quality randomness, but it should be enough to prevent unit tests from +// relying on a deterministic map ordering. By returning the address of a +// variable, we are able to get some randomness for free provided that ASLR is +// enabled. +static uint64_t _upb_Seed(void) { return (uint64_t)&_upb_seed; } static uint32_t _upb_Hash_NoSeed(const char* p, size_t n) { return _upb_Hash(p, n, _upb_Seed()); diff --git a/ruby/ext/google/protobuf_c/ruby-upb.c b/ruby/ext/google/protobuf_c/ruby-upb.c index ee3541c6c0..eea45d7695 100644 --- a/ruby/ext/google/protobuf_c/ruby-upb.c +++ b/ruby/ext/google/protobuf_c/ruby-upb.c @@ -11472,9 +11472,14 @@ uint32_t _upb_Hash(const void* p, size_t n, uint64_t seed) { return Wyhash(p, n, seed, kWyhashSalt); } -// Returns a seed for upb's hash function. For now this is just a hard-coded -// constant, but we are going to randomize it soon. -static uint64_t _upb_Seed(void) { return 0x69835f69597ec1cc; } +static const void* const _upb_seed; + +// Returns a random seed for upb's hash function. This does not provide +// high-quality randomness, but it should be enough to prevent unit tests from +// relying on a deterministic map ordering. By returning the address of a +// variable, we are able to get some randomness for free provided that ASLR is +// enabled. +static uint64_t _upb_Seed(void) { return (uint64_t)&_upb_seed; } static uint32_t _upb_Hash_NoSeed(const char* p, size_t n) { return _upb_Hash(p, n, _upb_Seed());