(scrub_env): change filtering algoritm from allowing everything except
a few bad cases to not allowing anything except a few non-dangerous cases git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@9304 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -1209,32 +1209,33 @@ init_env(void)
|
|||||||
/*
|
/*
|
||||||
* scrub_env()
|
* scrub_env()
|
||||||
*
|
*
|
||||||
* Remove variables from the environment that might cause login to
|
* We only accept the environment variables listed below.
|
||||||
* behave in a bad manner. To avoid this, login should be staticly
|
*/
|
||||||
* linked.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void scrub_env(void)
|
static void
|
||||||
|
scrub_env(void)
|
||||||
{
|
{
|
||||||
static char *remove[] = {
|
static const char *accept[] = {
|
||||||
"LD_", "_RLD_", "LIBPATH=",
|
"XAUTH=", "XAUTHORITY=", "DISPLAY=",
|
||||||
"IFS=", "ENV=",
|
"TERM=",
|
||||||
"LOCALDOMAIN=", "RES_OPTIONS=",
|
"EDITOR=",
|
||||||
"TERMINFO=", "TERMINFO_DIRS=", "TERMPATH=", "TERMCAP=/",
|
"PAGER=",
|
||||||
NULL
|
"PRINTER=",
|
||||||
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
char **cpp, **cpp2;
|
const char **cpp, **cpp2;
|
||||||
char **p;
|
const char **p;
|
||||||
|
|
||||||
for (cpp2 = cpp = environ; *cpp; cpp++) {
|
for (cpp2 = cpp = environ; *cpp; cpp++) {
|
||||||
for(p = remove; *p; p++)
|
for(p = accept; *p; p++)
|
||||||
if(strncmp(*cpp, *p, strlen(*p)) == 0)
|
if(strncmp(*cpp, *p, strlen(*p)) == 0)
|
||||||
break;
|
break;
|
||||||
if(*p == NULL)
|
if(*p != NULL)
|
||||||
*cpp2++ = *cpp;
|
*cpp2++ = *cpp;
|
||||||
}
|
}
|
||||||
*cpp2 = 0;
|
*cpp2 = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user