gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r1145 - GNUnet/src/util


From: durner
Subject: [GNUnet-SVN] r1145 - GNUnet/src/util
Date: Wed, 29 Jun 2005 14:08:47 -0700 (PDT)

Author: durner
Date: 2005-06-29 14:08:44 -0700 (Wed, 29 Jun 2005)
New Revision: 1145

Modified:
   GNUnet/src/util/statuscalls.c
Log:
Fix division by zero if NIC wasn't specified in config file.
When this was detected, the code didn't initialize some variables. That 
resulted in a SIGFPE. 

Modified: GNUnet/src/util/statuscalls.c
===================================================================
--- GNUnet/src/util/statuscalls.c       2005-06-29 20:05:33 UTC (rev 1144)
+++ GNUnet/src/util/statuscalls.c       2005-06-29 21:08:44 UTC (rev 1145)
@@ -139,84 +139,84 @@
        "LOAD",
        "INTERFACES");
     numInterfaces = 0;
-    MUTEX_UNLOCK(&statusMutex);
-    return;
   }
+       else {
+               /* The string containing the interfaces is formatted in the 
following way:
+                * each comma is replaced by '\0' and the pointers to the 
beginning of every
+                * interface are stored
+                */
+               numInterfaces = 0;
+               start = YES;
+               while (1) {
+                       if (*interfaces == '\0') {
+                               if (start == NO)
+                                       numInterfaces++;
+                                       break;
+                               }
+                               if ( ((*interfaces>='a') && (*interfaces<='z')) 
||
+                                       ((*interfaces>='A') && 
(*interfaces<='Z')) ||
+                                       ((*interfaces>='0') && 
(*interfaces<='9')) ) {
 
-  /* The string containing the interfaces is formatted in the following way:
-   * each comma is replaced by '\0' and the pointers to the beginning of every
-   * interface are stored
-   */
-  numInterfaces = 0;
-  start = YES;
-  while (1) {
-    if (*interfaces == '\0') {
-      if (start == NO)
-       numInterfaces++;
-      break;
-    }
-    if ( ((*interfaces>='a') && (*interfaces<='z')) ||
-        ((*interfaces>='A') && (*interfaces<='Z')) ||
-        ((*interfaces>='0') && (*interfaces<='9')) ) {
-      start = NO;
-    } else {
-      if (*interfaces != ',')
-       errexit(_("Interfaces string (%s) in configuration section '%s' under 
'%s' is malformed.\n"),
-               ifcs,
-               "LOAD",
-               "INTERFACES");
-      if (start == NO) {
-       start = YES;
-       numInterfaces++;
-      }
-    }
-    interfaces++;
-  }
-  if (numInterfaces <= 0) {
-    LOG(LOG_ERROR,
-       _("No network interfaces specified in the configuration file in section 
'%s' under '%s'.\n"),
-       "LOAD",
-       "INTERFACES");
-    MUTEX_UNLOCK(&statusMutex);
-    return;
-  }
+                                       start = NO;
+                                       } else {
+                                               if (*interfaces != ',')
+                                                       errexit(_("Interfaces 
string (%s) in configuration section '%s' under '%s' is malformed.\n"),
+                                                               ifcs,
+                                                               "LOAD",
+                                                               "INTERFACES");
+                                               if (start == NO) {
+                                                       start = YES;
+                                                       numInterfaces++;
+                                               }
+                                       }
+                               interfaces++;
+                       }
+                       if (numInterfaces <= 0) {
+                               LOG(LOG_ERROR,
+                                       _("No network interfaces specified in 
the configuration file in section '%s' under '%s'.\n"),
+                                       "LOAD",
+                                       "INTERFACES");
+                       }
+                       else {
+                               if (interfacePtrs != NULL) {
+                                       FREE(interfacePtrs[0]);
+                                       FREE(interfacePtrs);
+                       }
+                       interfacePtrs = MALLOC(sizeof(char*) * numInterfaces);
+                       last_net_results = MALLOC(sizeof(NetworkStats) * 
numInterfaces);
+                       memset(last_net_results, 0,
+                               sizeof(NetworkStats) * numInterfaces);
+               
+                       /* 2nd pass, this time remember the positions */
+                       interfaces = ifcs;
+                       numInterfaces = 0;
+                       start = YES;
+                       while (1) {
+                               if (*interfaces=='\0') {
+                                       if (start == NO)
+                                               numInterfaces++;
+                                       break;
+                               }
+                               if ( ((*interfaces>='a') && (*interfaces<='z')) 
||
+                                       ((*interfaces>='A') && 
(*interfaces<='Z')) ||
+                                       ((*interfaces>='0') && 
(*interfaces<='9')) ) {
+                     
+                     if (start == YES) {
+                       start = NO;
+                       interfacePtrs[numInterfaces] = interfaces;      
+                     }
+                               } else {
+                                       if (start == NO) {
+                                               start = YES;
+                                               *interfaces = '\0';     
+                                               numInterfaces++;
+                                       }
+                               }
+                               interfaces++;
+                       }
+               }
+       }
 
-  if (interfacePtrs != NULL) {
-    FREE(interfacePtrs[0]);
-    FREE(interfacePtrs);
-  }
-  interfacePtrs = MALLOC(sizeof(char*) * numInterfaces);
-  last_net_results = MALLOC(sizeof(NetworkStats) * numInterfaces);
-  memset(last_net_results, 0,
-        sizeof(NetworkStats) * numInterfaces);
-
-  /* 2nd pass, this time remember the positions */
-  interfaces = ifcs;
-  numInterfaces = 0;
-  start = YES;
-  while (1) {
-    if (*interfaces=='\0') {
-      if (start == NO)
-       numInterfaces++;
-      break;
-    }
-    if ( ((*interfaces>='a') && (*interfaces<='z')) ||
-        ((*interfaces>='A') && (*interfaces<='Z')) ||
-        ((*interfaces>='0') && (*interfaces<='9')) ) {
-      if (start == YES) {
-       start = NO;
-       interfacePtrs[numInterfaces] = interfaces;      
-      }
-    } else {
-      if (start == NO) {
-       start = YES;
-       *interfaces = '\0';     
-       numInterfaces++;
-      }
-    }
-    interfaces++;
-  }
-
   useBasicMethod
     = testConfigurationString("LOAD",
                              "BASICLIMITING",





reply via email to

[Prev in Thread] Current Thread [Next in Thread]