Date: Mon, 16 Feb 2009 21:56:17 +0000 (UTC) From: Colin Percival <cperciva@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r188699 - head/contrib/telnet/telnetd releng/7.0 releng/7.0/contrib/telnet/telnetd releng/7.0/sys/conf releng/7.1 releng/7.1/contrib/telnet/telnetd releng/7.1/sys/conf stable/7/contrib/... Message-ID: <200902162156.n1GLuHVX095729@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: cperciva Date: Mon Feb 16 21:56:17 2009 New Revision: 188699 URL: http://svn.freebsd.org/changeset/base/188699 Log: Correctly scrub telnetd's environment. Approved by: so (cperciva) Security: FreeBSD-SA-09:05.telnetd Modified: head/contrib/telnet/telnetd/sys_term.c Changes in other areas also in this revision: Modified: releng/7.0/UPDATING releng/7.0/contrib/telnet/telnetd/sys_term.c releng/7.0/sys/conf/newvers.sh releng/7.1/UPDATING releng/7.1/contrib/telnet/telnetd/sys_term.c releng/7.1/sys/conf/newvers.sh stable/7/contrib/telnet/telnetd/sys_term.c Modified: head/contrib/telnet/telnetd/sys_term.c ============================================================================== --- head/contrib/telnet/telnetd/sys_term.c Mon Feb 16 21:42:41 2009 (r188698) +++ head/contrib/telnet/telnetd/sys_term.c Mon Feb 16 21:56:17 2009 (r188699) @@ -1271,8 +1271,18 @@ scrub_env(void) char **cpp, **cpp2; const char **p; - - for (cpp2 = cpp = environ; *cpp; cpp++) { + char ** new_environ; + size_t count; + + /* Allocate space for scrubbed environment. */ + for (count = 1, cpp = environ; *cpp; count++, cpp++) + continue; + if ((new_environ = malloc(count * sizeof(char *))) == NULL) { + environ = NULL; + return; + } + + for (cpp2 = new_environ, cpp = environ; *cpp; cpp++) { int reject_it = 0; for(p = rej; *p; p++) @@ -1286,10 +1296,15 @@ scrub_env(void) for(p = acc; *p; p++) if(strncmp(*cpp, *p, strlen(*p)) == 0) break; - if(*p != NULL) - *cpp2++ = *cpp; + if(*p != NULL) { + if ((*cpp2++ = strdup(*cpp)) == NULL) { + environ = new_environ; + return; + } + } } *cpp2 = NULL; + environ = new_environ; } /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200902162156.n1GLuHVX095729>