X-Git-Url: http://git.meshlink.io/?p=meshlink;a=blobdiff_plain;f=src%2Fmeshlink.c;h=f504e5af116e1ec8006c7a46d37b3665dee0a89a;hp=5940c70e8e54fdac55e32c3d27e93a6a4bd7eb6c;hb=ea20fcfcded669ce8fbbda3a1f93f354ed254603;hpb=ac63b6adaf29c4143f9e106039011b9ebeb96b93 diff --git a/src/meshlink.c b/src/meshlink.c index 5940c70e..f504e5af 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -516,7 +516,7 @@ static bool try_bind(int port) { static int check_port(meshlink_handle_t *mesh) { for(int i = 0; i < 1000; i++) { - int port = 0x1000 + (rand() & 0x7fff); + int port = 0x1000 + prng(mesh, 0x8000); if(try_bind(port)) { free(mesh->myport); @@ -1286,6 +1286,8 @@ meshlink_handle_t *meshlink_open_ex(const meshlink_open_params_t *params) { mesh->log_cb = global_log_cb; mesh->log_level = global_log_level; + randomize(&mesh->prng_state, sizeof(mesh->prng_state)); + memcpy(mesh->dev_class_traits, default_class_traits, sizeof(default_class_traits)); if(usingname) { @@ -3522,9 +3524,6 @@ void handle_network_change(meshlink_handle_t *mesh, bool online) { static void __attribute__((constructor)) meshlink_init(void) { crypto_init(); - unsigned int seed; - randomize(&seed, sizeof(seed)); - srand(seed); } static void __attribute__((destructor)) meshlink_exit(void) {