INN commit: trunk/innd (rc.c)

INN Commit Russ_Allbery at isc.org
Tue Jul 31 21:21:50 UTC 2007


    Date: Tuesday, July 31, 2007 @ 14:21:50
  Author: iulius
Revision: 7612

Group blocks in incoming.conf are now correctly parsed and no longer cause segfaults.

Modified:
  trunk/innd/rc.c

------+
 rc.c |   24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

Modified: rc.c
===================================================================
--- rc.c	2007-07-31 18:42:17 UTC (rev 7611)
+++ rc.c	2007-07-31 21:21:50 UTC (rev 7612)
@@ -886,14 +886,19 @@
 	RCadddata(data, &infocount, K_BEGIN_GROUP, T_STRING, word);
 	groupcount++;
 	if (groupcount == 1) {
+          /* First group block. */
           group_params = groups = xmalloc(sizeof(REMOTEHOST));
 	}
 	else if (groupcount >= maxgroup) {
-          /* alloc 5 groups */
+          /* Alloc 5 groups for extra nested group blocks. */
           groups = xrealloc(groups, (groupcount + 4) * sizeof(REMOTEHOST));
-	  maxgroup += 5;
-	  group_params = groups + groupcount - 1;
-	}
+          maxgroup += 5;
+          group_params = groups + groupcount - 1;
+        }
+        else {
+          /* Nested group block (no need to extend groups). */
+          group_params++;
+        }
 	group_params->Label = word;
 	group_params->Skip = groupcount > 1 ?
 	  groups[groupcount - 2].Skip : default_params.Skip;
@@ -1063,10 +1068,13 @@
 	  RCadddata(data, &infocount, K_END_GROUP, T_STRING, NULL);
 	  group_params->Label = NULL;
 	  groupcount--;
-	  if (groupcount == 0)
-	    free(groups);
-	  else
-	    group_params--;
+         if (groupcount == 0) {
+           /* We are now outside a group block. */
+           free(groups);
+           maxgroup = 0;
+         } else {
+           group_params--;
+         }
 	}
 	else {
 	  syslog(L_ERROR, RIGHT_BRACE, LogName, linecount, filename);



More information about the inn-committers mailing list