mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-30 13:37:55 +00:00
fillRandom now uses random() instead of rand()
- a generic improvement that fixes NetBSD test failure.
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <dhcp/dhcp6.h>
|
||||
#include <dhcp/pkt6.h>
|
||||
@@ -220,7 +221,7 @@ void Dhcpv6Srv::setServerID() {
|
||||
|
||||
// Length of the identifier is company specific. I hereby declare
|
||||
// ISC "standard" of 6 bytes long pseudo-random numbers.
|
||||
srand(time(NULL));
|
||||
srandom(time(NULL));
|
||||
fillRandom(&srvid[6],&srvid[12]);
|
||||
|
||||
serverid_ = OptionPtr(new Option(Option::V6, D6O_SERVERID,
|
||||
|
@@ -15,7 +15,7 @@
|
||||
#ifndef __RANGE_UTIL_H_
|
||||
#define __RANGE_UTIL_H_ 1
|
||||
|
||||
#include <cstdlib>
|
||||
#include <stdlib.h>
|
||||
#include <algorithm>
|
||||
|
||||
// This header contains useful methods for conduction operations on
|
||||
@@ -58,7 +58,7 @@ template <typename Iterator>
|
||||
void
|
||||
fillRandom(Iterator begin, Iterator end) {
|
||||
for (Iterator x = begin; x != end; ++x) {
|
||||
*x = std::rand();
|
||||
*x = random();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -14,6 +14,7 @@
|
||||
|
||||
#include <config.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <vector>
|
||||
@@ -38,6 +39,8 @@ TEST(RangeUtilitiesTest, isZero) {
|
||||
|
||||
TEST(RangeUtilitiesTest, randomFill) {
|
||||
|
||||
srandom(time(NULL));
|
||||
|
||||
vector<uint8_t> vec1(16,0);
|
||||
vector<uint8_t> vec2(16,0);
|
||||
|
||||
|
Reference in New Issue
Block a user