Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 Feb 2018 17:20:10 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r330122 - head/etc/rc.d
Message-ID:  <201802281720.w1SHKAH3035077@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emaste
Date: Wed Feb 28 17:20:10 2018
New Revision: 330122
URL: https://svnweb.freebsd.org/changeset/base/330122

Log:
  rc.d/jail: avoid misinterpreting expr arguments
  
  (Due to some misconfiguration) I ended up with _mask set to
  "-v<something>", and /etc/rc.d/jail then failed with
  "expr: illegal option -- v".
  
  Use "expr --" so that variable content is never interpreted as an
  option.
  
  Reviewed by:	jamie
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D14535

Modified:
  head/etc/rc.d/jail

Modified: head/etc/rc.d/jail
==============================================================================
--- head/etc/rc.d/jail	Wed Feb 28 16:24:32 2018	(r330121)
+++ head/etc/rc.d/jail	Wed Feb 28 17:20:10 2018	(r330122)
@@ -316,7 +316,7 @@ jail_extract_address()
 
 	# Extract the prefix/netmask/prefixlen part by cutting off the address.
 	_mask=${_r}
-	_mask=`expr "${_mask}" : "${_addr}\(.*\)"`
+	_mask=`expr -- "${_mask}" : "${_addr}\(.*\)"`
 
 	# Identify type {inet,inet6}.
 	case "${_addr}" in
@@ -366,8 +366,8 @@ jail_handle_ips_option()
 	while [ ${#_x} -gt 0 ]; do
 		case "${_x}" in
 		*,*)	# Extract the first argument and strip it off the list.
-			_i=`expr "${_x}" : '^\([^,]*\)'`
-			_x=`expr "${_x}" : "^[^,]*,\(.*\)"`
+			_i=`expr -- "${_x}" : '^\([^,]*\)'`
+			_x=`expr -- "${_x}" : "^[^,]*,\(.*\)"`
 		;;
 		*)	_i=${_x}
 			_x=""



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802281720.w1SHKAH3035077>