[interchange-cvs] interchange - racke modified 2 files

interchange-core@icdevgroup.org interchange-core@icdevgroup.org
Sun Dec 29 19:23:01 2002


User:      racke
Date:      2002-12-30 00:22:01 GMT
Modified:  .        WHATSNEW
Modified:  lib/Vend Config.pm
Log:
Avoid infinite loops in catalog configuration caused by includes.

Revision  Changes    Path
2.74      +2 -0      interchange/WHATSNEW


rev 2.74, prev_rev 2.73
Index: WHATSNEW
===================================================================
RCS file: /var/cvs/interchange/WHATSNEW,v
retrieving revision 2.73
retrieving revision 2.74
diff -u -r2.73 -r2.74
--- WHATSNEW	27 Dec 2002 11:27:43 -0000	2.73
+++ WHATSNEW	30 Dec 2002 00:22:01 -0000	2.74
@@ -64,6 +64,8 @@
 * Minor cleanup in Data.pm, including ensuring $obj->{DELIMITER} 
   and $obj->{delimiter} match.
 
+* Avoid infinite loops in catalog configuration caused by includes.
+ 
 Filters
 -------
 



2.87      +12 -2     interchange/lib/Vend/Config.pm


rev 2.87, prev_rev 2.86
Index: Config.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Config.pm,v
retrieving revision 2.86
retrieving revision 2.87
diff -u -r2.86 -r2.87
--- Config.pm	13 Dec 2002 04:45:17 -0000	2.86
+++ Config.pm	30 Dec 2002 00:22:01 -0000	2.87
@@ -1,6 +1,6 @@
 # Vend::Config - Configure Interchange
 #
-# $Id: Config.pm,v 2.86 2002/12/13 04:45:17 jon Exp $
+# $Id: Config.pm,v 2.87 2002/12/30 00:22:01 racke Exp $
 #
 # Copyright (C) 1996-2002 Red Hat, Inc. <interchange@redhat.com>
 #
@@ -45,7 +45,7 @@
 use Vend::Util;
 use Vend::Data;
 
-$VERSION = substr(q$Revision: 2.86 $, 10);
+$VERSION = substr(q$Revision: 2.87 $, 10);
 
 my %CDname;
 
@@ -690,6 +690,7 @@
 	}
 
 	my(@include) = ($passed_file || $C->{ConfigFile});
+	my %include_hash = ($include[0] => 1);
 	my $done_one;
 	my ($db, $dname, $nm);
 	my ($before, $after);
@@ -706,6 +707,7 @@
 		# Backwards because of unshift;
 		for (@hidden_config) {
 			unshift @include, $_;
+			$include_hash{$_} = 1;
 		}
 
 		@hidden_config = grep -f $_, 
@@ -715,6 +717,7 @@
 
 		for (@hidden_config) {
 			push @include, $_;
+			$include_hash{$_} = 1;
 		}
 	}
 
@@ -736,6 +739,7 @@
 		}
 		close CMDLINE;
 		push @include, $fn;
+		$include_hash{$_} = 1;
 	}
 
 	my $allcfg;
@@ -825,6 +829,11 @@
 #print "found $_\n";
 			my $spec = $1;
 			$spec = substitute_variable($spec) if $C->{ParseVariables};
+			if ($include_hash{$spec}) {
+				config_error("Possible infinite loop through inclusion of $spec at line %s of %s, skipping", $., $configfile);
+				next;
+			}
+			$include_hash{$spec} = 1;
 			my $ref = [ $configfile, tell(CONFIG)];
 #print "saving config $configfile (pos $ref->[1])\n";
 			#unshift @include, [ $configfile, tell(CONFIG) ];
@@ -897,6 +906,7 @@
 	}
 	$done_one = 1;
 	close CONFIG;
+	delete $include_hash{$configfile};
 
 	# See if we have an active configuration database
 	if($C->{ConfigDatabase}->{ACTIVE}) {