[PATCH] RAND: Fix random initialization of rid.

Dominik Vogt dvogt at ffm.tc.iot.dtag.de
Thu Jul 29 10:08:25 CEST 2010


The old code generated rids between PDU_MIN_RID and PDU_MAX_RID - 2.
---
 src/uxsnmp.cpp |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/uxsnmp.cpp b/src/uxsnmp.cpp
index ce0447c..011eb24 100644
--- a/src/uxsnmp.cpp
+++ b/src/uxsnmp.cpp
@@ -716,7 +716,7 @@ void Snmp::init(int& status, IpAddress *addresses[2],
   // initialize the request_id
   eventListHolder->snmpEventList()->lock();
 //  srand(time(0)); // better than nothing
-  current_rid = (rand() % (PDU_MAX_RID - PDU_MIN_RID -1)) + PDU_MIN_RID;
+  current_rid = (rand() % (PDU_MAX_RID - PDU_MIN_RID +1)) + PDU_MIN_RID;
   debugprintf(4, "Initialized request_id to %i.", current_rid);
   eventListHolder->snmpEventList()->unlock();
 
-- 
1.5.5.6


--HlL+5n6rz5pIUxbD
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: attachment;
	filename="0002-64BIT-Fix-for-systems-with-integers-that-are-not-32.patch"



More information about the AGENTPP mailing list