Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 Mar 2015 11:56:53 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r280029 - in stable/9: tools/regression/usr.bin/env usr.bin/env
Message-ID:  <201503151156.t2FBurpa008957@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Sun Mar 15 11:56:52 2015
New Revision: 280029
URL: https://svnweb.freebsd.org/changeset/base/280029

Log:
  MFC r279779: env: Fix crash when -S string is not empty but no operand
  follows.
  
  split_spaces() set argc in main() incorrectly, which caused trouble for
  getopt().
  
  Examples:
    env -S '\c'
    env -S -i
  
  PR:		197769

Modified:
  stable/9/tools/regression/usr.bin/env/regress-env.rgdata
  stable/9/tools/regression/usr.bin/env/regress-sb.rb
  stable/9/usr.bin/env/envopts.c
Directory Properties:
  stable/9/tools/regression/usr.bin/env/   (props changed)
  stable/9/usr.bin/env/   (props changed)

Modified: stable/9/tools/regression/usr.bin/env/regress-env.rgdata
==============================================================================
--- stable/9/tools/regression/usr.bin/env/regress-env.rgdata	Sun Mar 15 11:56:43 2015	(r280028)
+++ stable/9/tools/regression/usr.bin/env/regress-env.rgdata	Sun Mar 15 11:56:52 2015	(r280029)
@@ -382,3 +382,36 @@ gblenv=OUTSIDEVAR=OutsideValue
    setenv:D=D_ThisisAlongstring_D1
    stdout:A_ThisisAlongstring_A1 B_ThisisAlongstring_B1 C_ThisisAlongstring_C1 D_ThisisAlongstring_D1 ScriptName: [%-script.pathname-%]
 [run]
+
+[test]
+   sb_args:sh
+   script:[%-testpgm.pathname-%] -S '\c' >/dev/null
+[run]
+[test]
+   sb_args:sh
+   script:[%-testpgm.pathname-%] -S'\c' >/dev/null
+[run]
+[test]
+   sb_args:sh
+   script:[%-testpgm.pathname-%] -u foo -S '\c' >/dev/null
+[run]
+[test]
+   sb_args:sh
+   script:[%-testpgm.pathname-%] -u foo -S'\c' >/dev/null
+[run]
+[test]
+   sb_args:sh
+   script:[%-testpgm.pathname-%] -S '-u bar \c' >/dev/null
+[run]
+[test]
+   sb_args:sh
+   script:[%-testpgm.pathname-%] -S'-u bar \c' >/dev/null
+[run]
+[test]
+   sb_args:sh
+   script:[%-testpgm.pathname-%] -u foo -S '-u bar \c' >/dev/null
+[run]
+[test]
+   sb_args:sh
+   script:[%-testpgm.pathname-%] -u foo -S'-u bar \c' >/dev/null
+[run]

Modified: stable/9/tools/regression/usr.bin/env/regress-sb.rb
==============================================================================
--- stable/9/tools/regression/usr.bin/env/regress-sb.rb	Sun Mar 15 11:56:43 2015	(r280028)
+++ stable/9/tools/regression/usr.bin/env/regress-sb.rb	Sun Mar 15 11:56:52 2015	(r280029)
@@ -346,6 +346,7 @@ class RGTestOptions
 	#   "just anything" that matches the general pattern.  There are
 	#   no blanks in the recognized values, but I use an x-tended
 	#   regexp and then add blanks to make it more readable.
+	optval.gsub!(/\[%- testpgm\.pathname -%\]/x, $testpgm)
 	optval.gsub!(/\[%- testpgm\.basename -%\]/x, File.basename($testpgm))
 	optval.gsub!(/\[%- script\.pathname  -%\]/x, $scriptfile)
 

Modified: stable/9/usr.bin/env/envopts.c
==============================================================================
--- stable/9/usr.bin/env/envopts.c	Sun Mar 15 11:56:43 2015	(r280028)
+++ stable/9/usr.bin/env/envopts.c	Sun Mar 15 11:56:52 2015	(r280029)
@@ -372,9 +372,9 @@ str_done:
 	*nextarg = NULL;
 
 	/* Update optind/argc/argv in the calling routine */
-	*origind = 1;
-	*origc += addcount;
+	*origc += addcount - *origind + 1;
 	*origv = newargv;
+	*origind = 1;
 }
 
 /**



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