You are not logged in.

#1 2004-08-08 21:44:47

tehdely
Member
Registered: 2004-02-20
Posts: 148
Website

[PATCH] Prevent double-includes

A tiny, tiny, patch.

I woke up last night at 2 AM wondering what would happen if you were to, say, include /etc/pacman.conf in /etc/pacman.conf.

Now I know.  Nothing big_smile

patch

diff -Naur orig/pacman-2.8.3/src/pacman.c pacman-2.8.3/src/pacman.c
--- orig/pacman-2.8.3/src/pacman.c    2004-08-04 00:57:17.000000000 -0500
+++ pacman-2.8.3/src/pacman.c    2004-08-08 17:08:00.000000000 -0500
@@ -101,6 +101,8 @@
 PMList *pm_packages = NULL;
 /* list of targets specified on command line */
 PMList *pm_targets  = NULL;
+/* list of parsed config files */
+PMList *pm_parsed = NULL;
 
 FILE *logfd    = NULL;
 char *lckfile  = "/tmp/pacman.lck";
@@ -3344,6 +3346,19 @@
     char section[256] = "";
     sync_t *sync = NULL;
 
+  /* catch recursive include directives and error out */
+
+  if (pm_parsed == NULL) {
+    pm_parsed = list_new();
+  }
+  
+  if (is_in(configfile,pm_parsed)) {
+    fprintf(stderr, "config: already parsed config file: %sn",configfile);
+    return(1);
+  }
+
+  list_add(pm_parsed, strdup(configfile));
+  
     if((fp = fopen(configfile, "r")) == NULL) {
         perror(configfile);
         return(1);
@@ -3802,6 +3817,7 @@
     FREE(pmo_xfercommand);
 
     FREELIST(pm_targets);
+  FREELIST(pm_parsed);
 
     /* this is segfaulting... quick fix for now 
     FREELISTPKGS(pm_packages);*/

[Arch GNUstep Repository] [ PKGBUILDS ]
[code][gnustep]
Server = ftp://blkwidow.lerp.com/pub/mirror/arch/gnustep[/code]

Offline

#2 2004-08-08 21:49:13

dpb
Member
From: Cyperspace?
Registered: 2004-04-11
Posts: 231

Re: [PATCH] Prevent double-includes

tehdely wrote:

I woke up last night at 2 AM wondering what would happen if you were to, say, include /etc/pacman.conf in /etc/pacman.conf.

Maybe you're a tiny, tiny bit addicted to ArchLinux if you wake up like that at 2am?  lol

Offline

#3 2004-08-08 21:50:26

tehdely
Member
Registered: 2004-02-20
Posts: 148
Website

Re: [PATCH] Prevent double-includes

dpb wrote:
tehdely wrote:

I woke up last night at 2 AM wondering what would happen if you were to, say, include /etc/pacman.conf in /etc/pacman.conf.

Maybe you're a tiny, tiny bit addicted to ArchLinux if you wake up like that at 2am?  lol

Well to tell the truth, I was woken up by somebody asking me that.  Causing me to wonder myself  big_smile


And he's a Gentoo user  lol


[Arch GNUstep Repository] [ PKGBUILDS ]
[code][gnustep]
Server = ftp://blkwidow.lerp.com/pub/mirror/arch/gnustep[/code]

Offline

#4 2004-08-08 22:21:16

dpb
Member
From: Cyperspace?
Registered: 2004-04-11
Posts: 231

Re: [PATCH] Prevent double-includes

tehdely wrote:

Well to tell the truth, I was woken up by somebody asking me that.  Causing me to wonder myself  big_smile

Ahh. Well, that's a bit better.  wink

Offline

Board footer

Powered by FluxBB