From: Jeff King Date: Thu, 23 Feb 2017 05:58:31 GMT Subject: Re: [PATCH v2] config: reject invalid VAR in 'git -c VAR=VAL command' Message-ID: <20170223055831.u3yofkby3c56t7l4@sigill.intra.peff.net> In-Reply-To: On Tue, Feb 21, 2017 at 01:24:38PM -0800, Junio C Hamano wrote: > The parsing of one-shot assignments of configuration variables that > come from the command line historically was quite loose and allowed > anything to pass. > > The configuration variable names that come from files are validated > in git_config_parse_source(), which uses get_base_var() that grabs > the
(and subsection) while making sure that
> consists of iskeychar() letters, the function itself that makes sure > that the first letter in is isalpha(), and get_value() > that grabs the remainder of the name while making sure > that it consists of iskeychar() letters. > > Perform an equivalent check in canonicalize_config_variable_name() > to catch invalid configuration variable names that come from the > command line. FWIW, the code looks OK here. It is a shame to duplicate the policy found in git_config_parse_key(), though. I wonder if we could make a master version of that which canonicalizes in-place, and then just wrap it for the git_config_parse_key() interface. Actually, I guess the function you just wrote _is_ that inner function, as long as it learned about the "quiet" flag. -Peff