diff options
| author | ghudson <ghudson@NetBSD.org> | 1995-10-19 12:47:28 +0000 |
|---|---|---|
| committer | ghudson <ghudson@NetBSD.org> | 1995-10-19 12:47:28 +0000 |
| commit | 75ec1de45829bef001e4956a5331b90484cb9044 (patch) | |
| tree | f67d61aab4eda35ca2f4977d54626928abd1879e /libexec | |
| parent | 84714731d371a8e47dd0d04fbd1cf426c0566a31 (diff) | |
Cleanup, from Mark Eichin.
Diffstat (limited to 'libexec')
| -rw-r--r-- | libexec/telnetd/state.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/libexec/telnetd/state.c b/libexec/telnetd/state.c index d84e9a8fb07..aabee6189b3 100644 --- a/libexec/telnetd/state.c +++ b/libexec/telnetd/state.c @@ -33,7 +33,7 @@ #ifndef lint /* from: static char sccsid[] = "@(#)state.c 8.1 (Berkeley) 6/4/93"; */ -static char *rcsid = "$Id: state.c,v 1.6 1995/10/18 05:44:26 ghudson Exp $"; +static char *rcsid = "$Id: state.c,v 1.7 1995/10/19 12:47:28 ghudson Exp $"; #endif /* not lint */ #include "telnetd.h" @@ -1050,6 +1050,18 @@ int env_ovalue = -1; # define env_ovalue OLD_ENV_VALUE #endif /* ENV_HACK */ +/* envvarok(char*) */ +/* check that variable is safe to pass to login or shell */ +static int +envvarok(varp) + char *varp; +{ + return (strncmp(varp, "LD_", strlen("LD_")) && + strncmp(varp, "_RLD_", strlen("_RLD_")) && + strcmp(varp, "LIBPATH") && + strcmp(varp, "IFS")); +} + /* * suboption() * @@ -1388,9 +1400,7 @@ suboption() case NEW_ENV_VAR: case ENV_USERVAR: *cp = '\0'; - if (strcmp(varp, "LD_LIBRARY_PATH") != 0 && - strcmp(varp, "LD_PRELOAD") != 0 && - strcmp(varp, "IFS") != 0) { + if (envvarok(varp)) { if (valp) (void)setenv(varp, valp, 1); else @@ -1411,10 +1421,12 @@ suboption() } } *cp = '\0'; - if (valp) - (void)setenv(varp, valp, 1); - else - unsetenv(varp); + if (envvarok(varp)) { + if (valp) + (void)setenv(varp, valp, 1); + else + unsetenv(varp); + } break; } /* end of case TELOPT_NEW_ENVIRON */ #if defined(AUTHENTICATION) |
