public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Matthieu Moy <Matthieu.Moy@grenoble-inp•fr>
To: Tanay Abhra <tanayabh@gmail•com>
Cc: git@vger•kernel.org, Ramkumar Ramachandra <artagnon@gmail•com>
Subject: Re: [PATCH] pretty.c: make git_pretty_formats_config return -1 on git_config_string failure
Date: Mon, 04 Aug 2014 17:45:44 +0200	[thread overview]
Message-ID: <vpqmwbki7h3.fsf@anie.imag.fr> (raw)
In-Reply-To: <1407163275-3006-1-git-send-email-tanayabh@gmail.com> (Tanay Abhra's message of "Mon, 4 Aug 2014 07:41:15 -0700")

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

> 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/

  reply	other threads:[~2014-08-04 15:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-04 14:41 [PATCH] pretty.c: make git_pretty_formats_config return -1 on git_config_string failure Tanay Abhra
2014-08-04 15:45 ` Matthieu Moy [this message]
2014-08-04 18:56   ` Eric Sunshine
2014-08-04 19:49     ` Matthieu Moy
2014-08-04 20:33   ` Jeff King
2014-08-04 21:06     ` Matthieu Moy
2014-08-04 21:56       ` [PATCH] config: teach "git -c" to recognize an empty string Jeff King
2014-08-04 22:25         ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=vpqmwbki7h3.fsf@anie.imag.fr \
    --to=matthieu.moy@grenoble-inp$(echo .)fr \
    --cc=artagnon@gmail$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=tanayabh@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox