X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=src%2Fcommon%2Fuuid.c;h=0e01c2185cc819327066dab0b9580059432d2d97;hb=edbac916fd984b0b50dc3f7cc352a94cb7f24287;hp=b0b74c967ab0cc1e64970708706bb886496dab3e;hpb=a1298db6cf0b806e968d9baa6da08ab78caf460b;p=lttng-tools.git diff --git a/src/common/uuid.c b/src/common/uuid.c index b0b74c967..0e01c2185 100644 --- a/src/common/uuid.c +++ b/src/common/uuid.c @@ -2,21 +2,14 @@ * Copyright (C) 2018 Jérémie Galarneau * Copyright (C) 2019 Michael Jeanson * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License, version 2.1 only, - * as published by the Free Software Foundation. + * SPDX-License-Identifier: LGPL-2.1-only * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include +#include +#include + #include #include #include @@ -88,18 +81,15 @@ int lttng_uuid_generate(lttng_uuid uuid_out) } if (!lttng_uuid_is_init) { - /* - * We don't need cryptographic quality randomness to - * generate UUIDs, seed rand with the epoch. - */ - const time_t epoch = time(NULL); - - if (epoch == (time_t) -1) { - ret = -1; + seed_t new_seed; + + ret = lttng_produce_best_effort_random_seed(&new_seed); + if (ret) { + ERR("Failed to initialize random seed while generating UUID"); goto end; } - srand(epoch); + srand(new_seed); lttng_uuid_is_init = true; }