Merge pull request #8398 from Robyt3/Base-secure_random_init-check

Ensure return value of `secure_random_init` is always checked
This commit is contained in:
heinrich5991 2024-05-26 10:21:26 +00:00 committed by GitHub
commit 5ad62b5732
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 3 deletions

View file

@ -2637,7 +2637,7 @@ void generate_password(char *buffer, unsigned length, const unsigned short *rand
* *
* @return `0` on success. * @return `0` on success.
*/ */
int secure_random_init(); [[nodiscard]] int secure_random_init();
/** /**
* Uninitializes the secure random module. * Uninitializes the secure random module.

View file

@ -6,8 +6,12 @@ int main(int argc, const char **argv)
{ {
CCmdlineFix CmdlineFix(&argc, &argv); CCmdlineFix CmdlineFix(&argc, &argv);
secure_random_init();
log_set_global_logger_default(); log_set_global_logger_default();
if(secure_random_init() != 0)
{
log_error("stun", "could not initialize secure RNG");
return -1;
}
if(argc < 2) if(argc < 2)
{ {

View file

@ -11,8 +11,12 @@ int main(int argc, const char **argv)
{ {
CCmdlineFix CmdlineFix(&argc, &argv); CCmdlineFix CmdlineFix(&argc, &argv);
secure_random_init();
log_set_global_logger_default(); log_set_global_logger_default();
if(secure_random_init() != 0)
{
log_error("twping", "could not initialize secure RNG");
return -1;
}
net_init(); net_init();
NETADDR BindAddr; NETADDR BindAddr;