This patch replaces the rand() function to the getrandom() syscall.
It was reported by the Coverity scan
rand() should not be used for security-related applications, because
linear congruential algorithms are too easy to break
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
#include <getopt.h>
#include <unistd.h>
#include <errno.h>
+#include <sys/random.h>
#include "lib/bluetooth.h"
#include "lib/hci.h"
uint16_t len = 2;
uint8_t pdu[4];
uint32_t cur_ee;
+ uint32_t val;
+
+ if (getrandom(&val, sizeof(val), 0) < 0)
+ return false;
pdu[0] = 0x06;
- pdu[1] = 90 + (rand() % 40);
+ pdu[1] = 90 + (val % 40);
if (expended_present) {
pdu[0] |= 0x08;