From 79c4c67cbacc6426ac73e8457491bd2c3c7a17ca Mon Sep 17 00:00:00 2001
From: obarun <eric@obarun.org>
Date: Sat, 22 Jun 2019 01:19:08 +0000
Subject: [PATCH] what a bug framboise!

---
 src/extra-tools/execl-envfile.c | 9 ++++++---
 src/lib66/environ.c             | 3 +--
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/extra-tools/execl-envfile.c b/src/extra-tools/execl-envfile.c
index f9f4b499..169e41f2 100644
--- a/src/extra-tools/execl-envfile.c
+++ b/src/extra-tools/execl-envfile.c
@@ -15,7 +15,7 @@
 #include <stdlib.h>
 #include <sys/stat.h>
 #include <unistd.h>
-#include <stdio.h>
+//#include <stdio.h>
 
 #include <oblibs/string.h>
 #include <oblibs/stralist.h>
@@ -169,23 +169,26 @@ int main (int argc, char const *const *argv, char const *const *envp)
 				xpathexec_run(argv[0],argv,envp) ;
 			}
 		}
+		
 		if (!file_readputsa(&src,path,file)) strerr_diefu4sys(111,"read file: ",path,"/",file) ;
 		if (!env_parsenclean(&modifs,&src)) strerr_diefu4x(111,"parse and clean environment of: ",path,"/",file)  ;
 		if (!env_split(&GAENV,&SAENV,&src)) strerr_diefu4x(111,"split environment of: ",path,"/",file) ;
+		if (genalloc_len(diuint32,&GAENV) > MAXVAR) strerr_dief4x(111,"to many variables in file: ",path,"/",file) ;
 	}
 	else
 	{
 		for (i = 0 ; i < genalloc_len(stralist,&toparse) ; i++)
 		{
 			src.len = 0 ;
-			size_t n = i + MAXVAR ;
+			size_t n = genalloc_len(diuint32,&GAENV) + MAXVAR ;
 			if (i > MAXFILE) strerr_dief2x(111,"to many file to parse in: ",path) ;
 			if (!file_readputsa(&src,path,gaistr(&toparse,i))) strerr_diefu4sys(111,"read file: ",path,"/",gaistr(&toparse,i)) ;
 			if (!env_parsenclean(&modifs,&src)) strerr_diefu4x(111,"parse and clean environment of: ",path,"/",gaistr(&toparse,i)) ;
 			if (!env_split(&GAENV,&SAENV,&src)) strerr_diefu4x(111,"split environment of: ",path,"/",gaistr(&toparse,i)) ;
-			if (genalloc_len(stralist,&toparse) > n) strerr_dief4x(111,"to many variables in file: ",path,"/",gaistr(&toparse,i)) ;
+			if (genalloc_len(diuint32,&GAENV) > n) strerr_dief4x(111,"to many variables in file: ",path,"/",gaistr(&toparse,i)) ;
 		}
 	}
+
 	genalloc_deepfree(stralist,&toparse,stra_free) ;
 	stralloc_free(&src) ;
 	
diff --git a/src/lib66/environ.c b/src/lib66/environ.c
index 7eacd099..9ec7b997 100644
--- a/src/lib66/environ.c
+++ b/src/lib66/environ.c
@@ -111,7 +111,6 @@ int env_split_one(char *line,genalloc *ga,stralloc *sa)
 	diuint32 tmp = DIUINT32_ZERO ;
 	k = line ;
 	v = line ;
-	
 	obstr_sep(&v,"=") ;
 	if (v == NULL) return 0 ;
 		
@@ -141,7 +140,7 @@ int env_split(genalloc *gaenv,stralloc *saenv,stralloc *src)
 		/** skip commented line or empty line*/
 		if (env_clean(&tmp) < 0) continue ;
 		if (*line)
-			if (!env_split_one(line,gaenv,saenv)) goto err ;
+			if (!env_split_one(tmp.s,gaenv,saenv)) goto err ;
 	}
 	genalloc_deepfree(stralist,&gatmp,stra_free) ;
 	stralloc_free(&tmp) ;
-- 
GitLab