diff --git a/implementation/security/include/policy_manager_impl.hpp b/implementation/security/include/policy_manager_impl.hpp index 4dd3a8654..8f6af3e77 100644 --- a/implementation/security/include/policy_manager_impl.hpp +++ b/implementation/security/include/policy_manager_impl.hpp @@ -153,10 +153,11 @@ class VSOMEIP_IMPORT_EXPORT policy_manager_impl mutable boost::shared_mutex policy_extension_paths_mutex_; //map[hostname, pair[path, map[complete path with UID/GID, control loading]] std::map>> policy_extension_paths_; + + bool check_routing_credentials_; #endif // !VSOMEIP_DISABLE_SECURITY bool is_configured_; - bool check_routing_credentials_; mutable std::mutex routing_credentials_mutex_; std::pair routing_credentials_; diff --git a/implementation/security/src/policy_manager_impl.cpp b/implementation/security/src/policy_manager_impl.cpp index 5841ea159..f90b7964c 100644 --- a/implementation/security/src/policy_manager_impl.cpp +++ b/implementation/security/src/policy_manager_impl.cpp @@ -46,9 +46,9 @@ policy_manager_impl::policy_manager_impl() allow_remote_clients_(true), check_whitelist_(false), policy_base_path_(""), + check_routing_credentials_(false), #endif // !VSOMEIP_DISABLE_SECURITY - is_configured_(false), - check_routing_credentials_(false) + is_configured_(false) { } diff --git a/implementation/service_discovery/src/service_discovery_impl.cpp b/implementation/service_discovery/src/service_discovery_impl.cpp index 3eb629da3..256ee17e3 100644 --- a/implementation/service_discovery/src/service_discovery_impl.cpp +++ b/implementation/service_discovery/src/service_discovery_impl.cpp @@ -114,11 +114,31 @@ service_discovery_impl::init() { initial_delay_max = tmp; } - std::random_device r; - std::mt19937 e(r()); - std::uniform_int_distribution distribution( - initial_delay_min, initial_delay_max); - initial_delay_ = std::chrono::milliseconds(distribution(e)); + try { + std::random_device r; + std::mt19937 e(r()); + std::uniform_int_distribution distribution( + initial_delay_min, initial_delay_max); + initial_delay_ = std::chrono::milliseconds(distribution(e)); + } catch (const std::exception& e) { + VSOMEIP_ERROR << "Failed to generate random initial delay: " << e.what(); + + // Fallback to the Mersenne Twister engine + const auto seed = static_cast( + std::chrono::duration_cast( + std::chrono::high_resolution_clock::now().time_since_epoch()) + .count()); + + std::mt19937 mtwister{seed}; + + // Interpolate between initial_delay bounds + initial_delay_ = std::chrono::milliseconds( + initial_delay_min + + (static_cast(mtwister()) * + static_cast(initial_delay_max - initial_delay_min) / + static_cast(std::mt19937::max() - + std::mt19937::min()))); + } repetitions_base_delay_ = std::chrono::milliseconds(