[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ntop-dev
Subject:    RE: [Ntop-dev] PR_TWTATGB - no Historical Protocol View
From:       "Burton Strauss" <Burton () ntopSupport ! com>
Date:       2005-08-19 14:24:12
Message-ID: 0MKoyl-1E67n43WVu-0007EG () mrelay ! perfora ! net
[Download RAW message or body]

Following up re (1)

Try the attached patch - it shifts the strncpy() to safe_snprintf() calls so
we get buffer length feedback in the log.

-----Burton


 

-----Original Message-----
From: ntop-dev-bounces@unipi.it [mailto:ntop-dev-bounces@unipi.it] On Behalf
Of Burton Strauss
Sent: Wednesday, August 17, 2005 9:00 AM
To: ntop-dev@Unipi.IT
Subject: RE: [Ntop-dev] PR_TWTATGB - no Historical Protocol View
norNetworkLoad graphs for LAN cards on Windows

(1) Why 64 ... Is it that it's big enough for your renamed network cards?
Or is that the actual size limit on A network card name?

<snip />

-----Burton
 

-----Original Message-----
From: ntop-dev-bounces@unipi.it [mailto:ntop-dev-bounces@unipi.it] On Behalf
Of Georger Araujo
Sent: Tuesday, August 16, 2005 11:36 AM
To: ntop-dev@Unipi.IT; ntop-dev@Unipi.IT
Subject: Re: [Ntop-dev] PR_TWTATGB - no Historical Protocol View nor
NetworkLoad graphs for LAN cards on Windows

Problem solved. Just had to change rrdInterface[32] to rrdInterface[64] in
line 2066 of plugins/rrdplugin.c and recompile. If anyone is interested I
made the mingw-compatible source available at
http://savefile.com/projects.php?pid=420840 - it's up-to-date with CVS and
running rock solid on my Windows XP Pro SP2 notebook for 1h20mins now.
Now I think I'll take a look at arbitrary graphs - ntop CVS still goes down
in flames with those.
Regards,

Georger

<snip />

["BMS0625-rrdinterfacelength.patch" (application/octet-stream)]

--- ntop/plugins/rrdPlugin.c 2005-08-18 16:52:31.000000000 -0500
+++ ntop/plugins/rrdPlugin.c 2005-08-19 09:14:02.951862406 -0500
@@ -2063,7 +2063,7 @@ static void printRRDPluginTrailer(void) 
 static void handleRRDHTTPrequest(char* url) {
   char buf[1024], *strtokState, *mainState, *urlPiece,
     rrdKey[64], rrdName[64], rrdTitle[128], rrdCounter[64], startTime[32], endTime[32],
-    rrdPrefix[32], rrdIP[32], rrdInterface[32], rrdPath[512];
+    rrdPrefix[32], rrdIP[32], rrdInterface[64], rrdPath[512];
   u_char action = FLAG_RRD_ACTION_NONE;
   char _which;
   int _dumpDomains, _dumpFlows, _dumpHosts, _dumpInterfaces,
@@ -2147,11 +2147,8 @@ static void handleRRDHTTPrequest(char* u
 	  else if(strcmp(value, "netflowSummary") == 0) action = FLAG_RRD_ACTION_NF_SUMMARY;
 	  else if(strcmp(value, "list") == 0) action = FLAG_RRD_ACTION_LIST;
 	} else if(strcmp(key, "key") == 0) {
-	  len = strlen(value);
-
-	  if(len >= sizeof(rrdKey)) len = sizeof(rrdKey)-1;
-	  strncpy(rrdKey, value, len);
-	  rrdKey[len] = '\0';
+	  safe_snprintf(__FILE__, __LINE__, rrdKey, sizeof(rrdKey), "%s", value);
+	  len = strlen(rrdKey);
 	  for(i=0; i<len; i++) if(rrdKey[i] == '+') rrdKey[i] = ' ';
 
           if(strncmp(value, "hosts/", strlen("hosts/")) == 0) {
@@ -2165,50 +2162,27 @@ static void handleRRDHTTPrequest(char* u
 	    rrdPrefix[0] = '\0';
           }
 	} else if(strcmp(key, CONST_ARBITRARY_IP) == 0) {
-          len = strlen(value);
-          if(len >= sizeof(rrdIP)) len = sizeof(rrdIP)-1;
-          strncpy(rrdIP, value, len);
-          rrdIP[len] = '\0';
+	  safe_snprintf(__FILE__, __LINE__, rrdIP, sizeof(rrdIP), "%s", value);
 	} else if(strcmp(key, CONST_ARBITRARY_INTERFACE) == 0) {
-          len = strlen(value);
-          if(len >= sizeof(rrdInterface)) len = sizeof(rrdInterface)-1;
-          strncpy(rrdInterface, value, len);
-          rrdInterface[len] = '\0';
+	  safe_snprintf(__FILE__, __LINE__, rrdInterface, sizeof(rrdInterface), "%s", value);
         } else if(strcmp(key, CONST_ARBITRARY_FILE) == 0) {
-          len = strlen(value);
-          if(len >= sizeof(rrdName)) len = sizeof(rrdName)-1;
-          strncpy(rrdName, value, len);
-          rrdName[len] = '\0';
+	  safe_snprintf(__FILE__, __LINE__, rrdName, sizeof(rrdName), "%s", value);
 	} else if(strcmp(key, "graphId") == 0) {
 	  graphId = atoi(value);
 	} else if(strcmp(key, "name") == 0) {
-	  len = strlen(value);
-
-	  if(len >= sizeof(rrdName)) len = sizeof(rrdName)-1;
-	  strncpy(rrdName, value, len);
+	  safe_snprintf(__FILE__, __LINE__, rrdName, sizeof(rrdName), "%s", value);
+	  len = strlen(rrdName);
   	  for(i=0; i<len; i++) if(rrdName[i] == '+') rrdName[i] = ' ';
-
-	  rrdName[len] = '\0';
 	} else if(strcmp(key, "counter") == 0) {
-	  len = strlen(value);
-
-	  if(len >= sizeof(rrdCounter)) len = sizeof(rrdCounter)-1;
-	  strncpy(rrdCounter, value, len);
+	  safe_snprintf(__FILE__, __LINE__, rrdCounter, sizeof(rrdCounter), "%s", value);
+	  len = strlen(rrdCounter);
   	  for(i=0; i<len; i++) if(rrdCounter[i] == '+') rrdCounter[i] = ' ';
-
-	  rrdCounter[len] = '\0';
 	} else if(strcmp(key, "title") == 0) {
           unescape(rrdTitle, sizeof(rrdTitle), value);
 	} else if(strcmp(key, "start") == 0) {
-	  len = strlen(value);
-
-	  if(len >= sizeof(startTime)) len = sizeof(startTime)-1;
-	  strncpy(startTime, value, len); startTime[len] = '\0';
+	  safe_snprintf(__FILE__, __LINE__, startTime, sizeof(startTime), "%s", value);
 	} else if(strcmp(key, "end") == 0) {
-	  len = strlen(value);
-
-	  if(len >= sizeof(endTime)) len = sizeof(endTime)-1;
-	  strncpy(endTime, value, len); endTime[len] = '\0';
+	  safe_snprintf(__FILE__, __LINE__, endTime, sizeof(endTime), "%s", value);
 	} else if(strcmp(key, "interval") == 0) {
 	  _dumpInterval = atoi(value);
           if(_dumpInterval < 1) _dumpInterval = 1 /* Min 1 second */;


_______________________________________________
Ntop-dev mailing list
Ntop-dev@unipi.it
http://listgateway.unipi.it/mailman/listinfo/ntop-dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic