From owner-svn-src-all@FreeBSD.ORG Sun Mar 8 14:12:45 2015 Return-Path: Delivered-To: svn-src-all@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 9FD7A7B2; Sun, 8 Mar 2015 14:12:45 +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 80F662B1; Sun, 8 Mar 2015 14:12:45 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t28ECjWZ054940; Sun, 8 Mar 2015 14:12:45 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t28ECidf054935; Sun, 8 Mar 2015 14:12:44 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201503081412.t28ECidf054935@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Sun, 8 Mar 2015 14:12:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r279779 - in head: tools/regression/usr.bin/env usr.bin/env X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Mar 2015 14:12:45 -0000 Author: jilles Date: Sun Mar 8 14:12:43 2015 New Revision: 279779 URL: https://svnweb.freebsd.org/changeset/base/279779 Log: 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 MFC after: 1 week Modified: head/tools/regression/usr.bin/env/regress-env.rgdata head/tools/regression/usr.bin/env/regress-sb.rb head/usr.bin/env/envopts.c Modified: head/tools/regression/usr.bin/env/regress-env.rgdata ============================================================================== --- head/tools/regression/usr.bin/env/regress-env.rgdata Sun Mar 8 13:52:07 2015 (r279778) +++ head/tools/regression/usr.bin/env/regress-env.rgdata Sun Mar 8 14:12:43 2015 (r279779) @@ -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: head/tools/regression/usr.bin/env/regress-sb.rb ============================================================================== --- head/tools/regression/usr.bin/env/regress-sb.rb Sun Mar 8 13:52:07 2015 (r279778) +++ head/tools/regression/usr.bin/env/regress-sb.rb Sun Mar 8 14:12:43 2015 (r279779) @@ -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: head/usr.bin/env/envopts.c ============================================================================== --- head/usr.bin/env/envopts.c Sun Mar 8 13:52:07 2015 (r279778) +++ head/usr.bin/env/envopts.c Sun Mar 8 14:12:43 2015 (r279779) @@ -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; } /**