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

Re: [PATCH] pretty.c: make git_pretty_formats_config return -1 on git_config_string failure

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Aug 4, 2014, 18:56 UTC
Message-ID
<CAPig+cRo05mG9yeU61VSjAvXWRHU9soaaH-Cv7MKoxZ=it15Rw@mail.gmail.com>
In-Reply-To
<vpqmwbki7h3.fsf@anie.imag.fr>

On Mon, Aug 4, 2014 at 11:45 AM, Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> wrote:

Show 10 quoted lines
> Tanay Abhra <tanayabh@gmail.com> writes:
>
>> `git_pretty_formats_config()` continues without checking git_config_string's
>> return value which can lead to a SEGFAULT.
>
> Indeed, without the patch:
>
> $ git -c pretty.my= log --pretty=my
> error: Missing value for 'pretty.my'
> zsh: segmentation fault  git -c pretty.my= log --pretty=my

This probably should be formalized as a proper test and included with Tanay's patch.

Show 22 quoted lines
>> diff --git a/pretty.c b/pretty.c
>> index 3a1da6f..72dbf55 100644
>> --- a/pretty.c
>> +++ b/pretty.c
>> @@ -65,7 +65,9 @@ static int git_pretty_formats_config(const char *var, const char *value, void *c
>>
>>       commit_format->name = xstrdup(name);
>>       commit_format->format = CMIT_FMT_USERFORMAT;
>> -     git_config_string(&fmt, var, value);
>> +     if (git_config_string(&fmt, var, value))
>> +             return -1;
>> +
>
> Ack-ed-by: Matthieu Moy <Matthieu.Moy@imag.fr>
>
> My first thought reading this was "why not rewrite using non-callback
> API?", but this particular call to git_config needs to iterate over
> config keys anyway.
>
> --
> Matthieu Moy
> http://www-verimag.imag.fr/~moy/
Previous: Matthieu MoyNext: Matthieu Moy
Message 3 of 8 in “pretty.c: make git_pretty_formats_config return -1 on git_config_string failure”
  1. pretty.c: make git_pretty_formats_config return -1 on git_config_string failureTanay Abhra, Aug 4, 2014
  2. Matthieu MoyAug 4, 2014
  3. Eric SunshineAug 4, 2014
  4. Matthieu MoyAug 4, 2014
  5. Jeff KingAug 4, 2014
  6. Matthieu MoyAug 4, 2014
  7. config: teach "git -c" to recognize an empty stringJeff King, Aug 4, 2014
  8. Junio C HamanoAug 4, 2014

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.