diff mbox series

[ovs-dev,2/7] sflow: Replace libc's random() function with the OVS's random_range().

Message ID a1a819ab0b8aa98e96eb168d2fbd314676298fe8.1716807712.git.echaudro@redhat.com
State Changes Requested
Headers show
Series [ovs-dev,1/7] Coverity: Fix Coverity `Unintentional integer overflow` reports. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/intel-ovs-compilation success test: success

Commit Message

Eelco Chaudron May 27, 2024, 11:01 a.m. UTC
Coverity has flagged the use of a potentially unsafe function.
Although this is not a concern in this case since it's not used for
encryption, we should replace it with the OVS implementation to
achieve better randomness.

Fixes: c72e245a0e2c ("Add InMon's sFlow Agent library to the build system.")
Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
---
 lib/sflow_poller.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lib/sflow_poller.c b/lib/sflow_poller.c
index 9e6a487bc..46e40cbd4 100644
--- a/lib/sflow_poller.c
+++ b/lib/sflow_poller.c
@@ -6,6 +6,7 @@ 
  */
 
 #include "sflow_api.h"
+#include "random.h"
 
 /*_________________--------------------------__________________
   _________________    sfl_poller_init       __________________
@@ -88,7 +89,7 @@  void sfl_poller_set_sFlowCpInterval(SFLPoller *poller, u_int32_t sFlowCpInterval
 	   Another smoothing factor is that the tick() function called here is usually
 	   driven from a fairly "soft" polling loop rather than a hard real-time event.
 	*/
-        poller->countersCountdown = 1 + (random() % sFlowCpInterval);
+        poller->countersCountdown = 1 + random_range(sFlowCpInterval);
     }
     else {
         /* Setting sFlowCpInterval to 0 disables counter polling altogether.  Thanks to