git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-sh-setup.sh: fix missing double quotes variables

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 19, 2016, 17:59 UTC
Message-ID
<xmqqvb15vz3y.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<xmqqinx5yijm.fsf@gitster.mtv.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 16 quoted lines
> LE Manh Cuong <cuong.manhle.vn@gmail.com> writes:
>
>> It's not only people shooting their foot, but also from malicious user.
>> Given that `curl url | sudo sh/bash` is often found in many instructions,
>> an end user may not be noticed about the environment variable injection
>> from their side.
>>
>> IMHO, it's better if  git can protect the end users in this situation.
>
> Huh?  For those who run `curl url | sudo sh`, I do not think the
> incoming script setting and exporting LV to an arbitrary value and
> runing Git is not the top thing they need worry about.
>
> While I think enclosing the string in dq is an improvement (as I
> said already), I still do think your use of the v-word is making a
> mountain out of an anthill.

I failed to say why I found the dq is an improvement, but that should be in the log message of this commit. Off the top of my head, something like:

	We often make sure an environment variable is set to
	something, either set by the user (in which case we do not
	molest it) or set it to our default value (otherwise), with
		: ${VAR=default value}
	i.e. running the no-op command ":" with ${VAR} as its
	parameters (or the default value we supply), relying on that
	":" is a no-op.
	This pattern, even though it is no-op from correctness point
	of view, still can be expensive if the existing value in VAR
	has shell glob (because they will be expanded against
	filesystem entities) and IFS whitespaces (because the value
	need to be split into multiple parameters).  Our invocation
	of ":" command does not care if the parameter given to it is
	after the value in VAR goes through these processing.
	Enclosing the whole thing in double-quote, i.e.
		: "${VAR=default value}"
	avoids paying the unnecessary cost, so let's do so.
Previous: LE Manh CuongNext: LE Manh Cuong
Message 8 of 11 in “git-sh-setup.sh: fix missing double quotes variables”
  1. git-sh-setup.sh: fix missing double quotes variablesLE Manh Cuong, Jun 18, 2016
  2. LE Manh Cuong, Jun 18, 2016
  3. git-sh-setup.sh: fix missing double quotes variablesLE Manh Cuong, Jun 18, 2016
  4. Junio C HamanoJun 19, 2016
  5. LE Manh CuongJun 19, 2016
  6. Junio C HamanoJun 19, 2016
  7. LE Manh CuongJun 19, 2016
  8. Junio C HamanoJun 19, 2016
  9. LE Manh CuongJun 19, 2016
  10. Junio C HamanoJun 19, 2016
  11. Junio C HamanoJun 19, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.