mirror of
https://github.com/sheumann/telnetd.git
synced 2025-08-09 20:25:22 +00:00
(scrub_env): change to only accept a listed set of variables,
including only non-filename contents for TERMCAP git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@69825 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
This commit is contained in:
@@ -1839,34 +1839,48 @@ addarg(argv, val)
|
|||||||
/*
|
/*
|
||||||
* scrub_env()
|
* scrub_env()
|
||||||
*
|
*
|
||||||
* Remove a few things from the environment that
|
* We only accept the environment variables listed below.
|
||||||
* don't need to be there.
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
scrub_env()
|
scrub_env()
|
||||||
{
|
{
|
||||||
register char **cpp, **cpp2;
|
static const char *reject[] = {
|
||||||
|
"TERMCAP=/",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
for (cpp2 = cpp = environ; *cpp; cpp++) {
|
static const char *accept[] = {
|
||||||
#ifdef __FreeBSD__
|
"XAUTH=", "XAUTHORITY=", "DISPLAY=",
|
||||||
if (strncmp(*cpp, "LD_LIBRARY_PATH=", 16) &&
|
"TERM=",
|
||||||
strncmp(*cpp, "LD_PRELOAD=", 11) &&
|
"EDITOR=",
|
||||||
#else
|
"PAGER=",
|
||||||
if (strncmp(*cpp, "LD_", 3) &&
|
"LOGNAME=",
|
||||||
strncmp(*cpp, "_RLD_", 5) &&
|
"POSIXLY_CORRECT=",
|
||||||
strncmp(*cpp, "LIBPATH=", 8) &&
|
"PRINTER=",
|
||||||
#endif
|
NULL
|
||||||
strncmp(*cpp, "LOCALDOMAIN=", 12) &&
|
};
|
||||||
strncmp(*cpp, "RES_OPTIONS=", 12) &&
|
|
||||||
strncmp(*cpp, "TERMINFO=", 9) &&
|
char **cpp, **cpp2;
|
||||||
strncmp(*cpp, "TERMINFO_DIRS=", 14) &&
|
const char **p;
|
||||||
strncmp(*cpp, "TERMPATH=", 9) &&
|
|
||||||
strncmp(*cpp, "TERMCAP=/", 9) &&
|
for (cpp2 = cpp = environ; *cpp; cpp++) {
|
||||||
strncmp(*cpp, "ENV=", 4) &&
|
int reject_it = 0;
|
||||||
strncmp(*cpp, "IFS=", 4))
|
|
||||||
*cpp2++ = *cpp;
|
for(p = reject; *p; p++)
|
||||||
}
|
if(strncmp(*cpp, *p, strlen(*p)) == 0) {
|
||||||
*cpp2 = 0;
|
reject_it = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (reject_it)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for(p = accept; *p; p++)
|
||||||
|
if(strncmp(*cpp, *p, strlen(*p)) == 0)
|
||||||
|
break;
|
||||||
|
if(*p != NULL)
|
||||||
|
*cpp2++ = *cpp;
|
||||||
|
}
|
||||||
|
*cpp2 = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user