svn commit: r241019 - head/usr.sbin/bsdconfig/share
Devin Teske
dteske at FreeBSD.org
Fri Sep 28 01:39:26 UTC 2012
Author: dteske
Date: Fri Sep 28 01:39:25 2012
New Revision: 241019
URL: http://svn.freebsd.org/changeset/base/241019
Log:
Sanitize varname argument in f_sysrc_find. This is as much for security as it
is for sanity.
Reviewed by: jilles
Approved by: adrian (co-mentor)
Modified:
head/usr.sbin/bsdconfig/share/sysrc.subr
Modified: head/usr.sbin/bsdconfig/share/sysrc.subr
==============================================================================
--- head/usr.sbin/bsdconfig/share/sysrc.subr Fri Sep 28 01:04:10 2012 (r241018)
+++ head/usr.sbin/bsdconfig/share/sysrc.subr Fri Sep 28 01:39:25 2012 (r241019)
@@ -49,6 +49,17 @@ f_include_lang $BSDCFG_LIBE/include/mess
SUCCESS=0
FAILURE=1
+#
+# Valid characters that can appear in an sh(1) variable name
+#
+# Please note that the character ranges A-Z and a-z should be avoided because
+# these can include accent characters (which are not valid in a variable name).
+# For example, A-Z matches any character that sorts after A but before Z,
+# including A and Z. Although ASCII order would make more sense, that is not
+# how it works.
+#
+VALID_VARNAME_CHARS="0-9ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_"
+
############################################################ FUNCTIONS
# f_clean_env [ --except $varname ... ]
@@ -243,14 +254,16 @@ f_sysrc_get_default()
#
f_sysrc_find()
{
- local varname="$1"
+ local varname="${1%%[!$VALID_VARNAME_CHARS]*}"
local regex="^[[:space:]]*$varname="
local rc_conf_files="$( f_sysrc_get rc_conf_files )"
local conf_files=
local file
# Check parameters
- [ "$varname" ] || return $FAILURE
+ case "$varname" in
+ ""|[0-9]*) return $FAILURE
+ esac
#
# If RC_CONFS is defined, set $rc_conf_files to an explicit
More information about the svn-src-head
mailing list