Robbert,
now you have repository access: go ahead and commit them all.

Cheers, Luca

Kouprie, Robbert wrote:

Hi,

This is a revised version of the patch with Burton's suggestion.

Same bug found in report.c + small cleanups.

Robbert

--- ntop/report.c.orig 2004-06-24 14:39:58.664999880 +0200
+++ ntop/report.c 2004-06-24 15:39:47.752375664 +0200
@@ -4312,7 +4312,7 @@

/* if myGlobals.domainName == NULL -> print all domains */
void printDomainStats(char* domainName, int sortedColumn, int revertOrder, int 
pageNum) {
-  u_int idx, tmpIdx, numEntries=0, printedEntries=0, len, maxHosts;
+  u_int idx, tmpIdx, numEntries=0, printedEntries=0, maxHosts;
  u_short keyValue=0, i;
  HostTraffic *el;
  char buf[LEN_GENERAL_WORK_BUFFER];
@@ -4334,16 +4334,18 @@
  printHTMLheader(buf, NULL, 0);

  maxHosts = myGlobals.device[myGlobals.actualReportDeviceId].hostsno; /* save it as 
it can change */
-  len = sizeof(DomainStats)*maxHosts;
-  tmpStats = (DomainStats*)mallocAndInitWithReportWarn(len, "printDomainStats");
+  tmpStats = (DomainStats*)mallocAndInitWithReportWarn(maxHosts*sizeof(DomainStats), 
"printDomainStats");
  if(tmpStats == NULL)
      return;

  /* Fix below courtesy of Francis Pintos < [EMAIL PROTECTED]> */
-  len = sizeof(DomainStats**)*maxHosts;
-  stats = (DomainStats**)mallocAndInitWithReportWarn(len, "printDomainStats(2)");
+  stats = (DomainStats**)mallocAndInitWithReportWarn(maxHosts*sizeof(DomainStats*), 
"printDomainStats(2)");
  if(stats == NULL)
+  {
+      /* also free the block of memory allocated a few lines up */
+      if (tmpStats != NULL) free(tmpStats);
      return;
+  }

  /* traceEvent(CONST_TRACE_INFO, "'%s' '%d' '%d'", domainName, sortedColumn, 
revertOrder); */

@@ -4508,6 +4510,7 @@
    } else {
      char tmpBuf[64], *hostLink;
      int blankId;
+      u_int len;

accessAddrResMutex("getHostIcon");




------------------------------------------------------------------------

_______________________________________________
Ntop-dev mailing list
[EMAIL PROTECTED]
http://listgateway.unipi.it/mailman/listinfo/ntop-dev




--
Luca Deri <[EMAIL PROTECTED]>     http://luca.ntop.org/
Hacker: someone who loves to program and enjoys being
clever about it - Richard Stallman

_______________________________________________
Ntop-dev mailing list
[EMAIL PROTECTED]
http://listgateway.unipi.it/mailman/listinfo/ntop-dev

Reply via email to