From owner-svn-src-stable-9@FreeBSD.ORG Sun Mar 15 11:56:54 2015 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 00A3CC69; Sun, 15 Mar 2015 11:56:53 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D5F3A7E0; Sun, 15 Mar 2015 11:56:53 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t2FBurUu008966; Sun, 15 Mar 2015 11:56:53 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t2FBurpa008957; Sun, 15 Mar 2015 11:56:53 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201503151156.t2FBurpa008957@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Sun, 15 Mar 2015 11:56:53 +0000 (UTC) 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 X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Mar 2015 11:56:54 -0000 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; } /**