Subject: kde2: bugfix for kdm
To: None <tech-pkg@netbsd.org>
From: Ingolf Steinbach <ingolf@jellonet.de>
List: tech-pkg
Date: 01/03/2001 15:09:19
--gBBFr7Ir9EOA20Yy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hi,
while trying Nick's KDE2 packages, I have found a bug in
kdm/server.c (from kdebase):
The StartClient() function calls setusercontext() which
manipulates the process environment (e.g. sets the PATH
variable). This process environment has previously been
set to an array created on the *stack*.
setusercontext() calls setenv() which may need to enlarge
the process environment via realloc() (and it really does
so!) which fails as the environment was not allocated on
the heap.
The attached patch file seems to fix the problem.
Regards
Ingolf
--
Ingolf Steinbach Balin@IRCnet ICQ#60829470
PGP: 0x7B3B5661 213C 828E 0C92 16B5 05D0 4D5B A324 EC04
--gBBFr7Ir9EOA20Yy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="kdm.diff"
--- session.c.orig Tue Sep 26 20:16:00 2000
+++ session.c Wed Jan 3 14:57:49 2001
@@ -704,7 +704,7 @@
extern char **environ;
char ** e;
struct passwd *pwd;
- char *envinit[1];
+ char **envinit = NULL;
#endif
if (verify->argv) {
@@ -749,6 +749,14 @@
* We need to do this before setusercontext() because that may
* set or reset some environment variables.
*/
+
+ envinit = malloc(sizeof(char*));
+ if (NULL == envinit) {
+ LogError("malloc initial environment failed, errno=%d\n",
+ errno);
+ return 0;
+ }
+
envinit[0] = NULL;
environ = envinit;
--gBBFr7Ir9EOA20Yy--