Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/libexec/telnetd (scrub_env): change to only accept a listed ...
details: https://anonhg.NetBSD.org/src/rev/39a18cda0570
branches: trunk
changeset: 500252:39a18cda0570
user: assar <assar%NetBSD.org@localhost>
date: Sat Dec 09 00:50:21 2000 +0000
description:
(scrub_env): change to only accept a listed set of variables,
including only non-filename contents for TERMCAP
diffstat:
libexec/telnetd/sys_term.c | 59 +++++++++++++++++++++++++++++----------------
1 files changed, 38 insertions(+), 21 deletions(-)
diffs (88 lines):
diff -r fa6f4008936b -r 39a18cda0570 libexec/telnetd/sys_term.c
--- a/libexec/telnetd/sys_term.c Sat Dec 09 00:47:57 2000 +0000
+++ b/libexec/telnetd/sys_term.c Sat Dec 09 00:50:21 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_term.c,v 1.19 2000/11/19 20:17:39 christos Exp $ */
+/* $NetBSD: sys_term.c,v 1.20 2000/12/09 00:50:21 assar Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)sys_term.c 8.4+1 (Berkeley) 5/30/95";
#else
-__RCSID("$NetBSD: sys_term.c,v 1.19 2000/11/19 20:17:39 christos Exp $");
+__RCSID("$NetBSD: sys_term.c,v 1.20 2000/12/09 00:50:21 assar Exp $");
#endif
#endif /* not lint */
@@ -1882,33 +1882,50 @@
/*
* scrub_env()
*
- * Remove a few things from the environment that
- * don't need to be there.
+ * We only accept the environment variables listed below.
*/
+
void
scrub_env()
{
- register char **cpp, **cpp2;
+ static const char *reject[] = {
+ "TERMCAP=/",
+ NULL
+ };
+
+ static const char *accept[] = {
+ "XAUTH=", "XAUTHORITY=", "DISPLAY=",
+ "TERM=",
+ "EDITOR=",
+ "PAGER=",
+ "LOGNAME=",
+ "POSIXLY_CORRECT=",
+ "TERMCAP=",
+ "PRINTER=",
+ NULL
+ };
+
+ char **cpp, **cpp2;
+ const char **p;
for (cpp2 = cpp = environ; *cpp; cpp++) {
- if (strncmp(*cpp, "LD_", 3) &&
- strncmp(*cpp, "_RLD_", 5) &&
- strncmp(*cpp, "LIBPATH=", 8) &&
- strncmp(*cpp, "LOCALDOMAIN=", 12) &&
- strncmp(*cpp, "RES_OPTIONS=", 12) &&
- strncmp(*cpp, "TERMINFO=", 9) &&
- strncmp(*cpp, "TERMINFO_DIRS=", 14) &&
- /*
- * We dissallow TERMPATH and TERMCAP
- * entries that reference files.
- */
- strncmp(*cpp, "TERMPATH=", 9) &&
- strncmp(*cpp, "TERMCAP=/", 9) &&
- strncmp(*cpp, "ENV=", 4) &&
- strncmp(*cpp, "IFS=", 4))
+ int reject_it = 0;
+
+ for(p = reject; *p; p++)
+ if(strncmp(*cpp, *p, strlen(*p)) == 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 = 0;
+ *cpp2 = NULL;
}
/*
Home |
Main Index |
Thread Index |
Old Index