public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Thomas Rast <trast@inf•ethz.ch>
To: Jharrod LaFon <jlafon@eyesopen•com>
Cc: "git@vger•kernel.org" <git@vger•kernel.org>,
	Jens Lehmann <Jens.Lehmann@web•de>
Subject: Re: [PATCH] Git segmentation faults if submodule path is empty.
Date: Fri, 16 Aug 2013 09:50:50 +0200	[thread overview]
Message-ID: <87zjsif50l.fsf@linux-k42r.v.cablecom.net> (raw)
In-Reply-To: <277BEB82-D618-48D9-A276-4B0E76A11A38@eyesopen.com> (Jharrod LaFon's message of "Thu, 15 Aug 2013 18:51:05 -0700")

Jharrod LaFon <jlafon@eyesopen•com> writes:

> Git fails due to a segmentation fault if a submodule path is empty.
> Here is an example .gitmodules that will cause a segmentation fault:
> [submodule "foo-module"]
>     path
>     url = http://host/repo.git
> $ git status
> Segmentation fault (core dumped)

Can you turn this into a test to guard against the bug reappearing?

> This occurs because in the function parse_submodule_config_option, the
> variable 'value' is assumed not to be null, and when passed as an
> argument to xstrdup a segmentation fault occurs if it is indeed null.
> This is the case when using the .gitmodules example above.
>
> This patch addresses the issue by returning from the function if
> 'value' is null before the call to xstrdup is made.
>
> Signed-off-by: Jharrod LaFon <jlafon <at> eyesopen.com>
> ---
>  submodule.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/submodule.c b/submodule.c
> index 1821a5b..880f21b 100644
> --- a/submodule.c
> +++ b/submodule.c
> @@ -130,7 +130,7 @@ int parse_submodule_config_option(const char *var, const char *value)
>  	const char *name, *key;
>  	int namelen;
>  
> -	if (parse_config_key(var, "submodule", &name, &namelen, &key) < 0 || !name)
> +	if (parse_config_key(var, "submodule", &name, &namelen, &key) < 0 || !name || !value)
>  		return 0;
>  
>  	if (!strcmp(key, "path")) {

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

      parent reply	other threads:[~2013-08-16  7:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-16  1:51 [PATCH] Git segmentation faults if submodule path is empty Jharrod LaFon
2013-08-16  6:48 ` Jens Lehmann
2013-08-16 13:09   ` Jeff King
2013-08-16 13:14     ` Jeff King
2013-08-16 15:12       ` Jharrod LaFon
2013-08-16 17:59         ` Jharrod LaFon
2013-08-16 20:52           ` Jeff King
2013-08-19 16:26             ` Jharrod LaFon
2013-08-19 18:56               ` Junio C Hamano
2013-08-19 20:48                 ` Jeff King
     [not found]                 ` <30EC6002-1044-41E0-8700-1F210A6CA882@eyesopen.com>
2013-08-19 20:54                   ` Junio C Hamano
2013-08-20  0:26                     ` Jharrod LaFon
2013-08-16  7:50 ` Thomas Rast [this message]

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=87zjsif50l.fsf@linux-k42r.v.cablecom.net \
    --to=trast@inf$(echo .)ethz.ch \
    --cc=Jens.Lehmann@web$(echo .)de \
    --cc=git@vger$(echo .)kernel.org \
    --cc=jlafon@eyesopen$(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