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

Re: [PATCH] Git segmentation faults if submodule path is empty.

From
Thomas Rast <trast@inf.ethz.ch>
Date
Aug 16, 2013, 07:50 UTC
Message-ID
<87zjsif50l.fsf@linux-k42r.v.cablecom.net>
In-Reply-To
<277BEB82-D618-48D9-A276-4B0E76A11A38@eyesopen.com>
Jharrod LaFon <jlafon@eyesopen.com> writes:
Show 7 quoted lines
> 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?
Show 26 quoted lines
> 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
Previous: Jeff KingNext: Junio C Hamano
Message 11 of 13 in “Git segmentation faults if submodule path is empty.”
  1. Git segmentation faults if submodule path is empty.Jharrod LaFon, Aug 16, 2013
  2. Jens LehmannAug 16, 2013
  3. Jeff KingAug 16, 2013
  4. Jeff KingAug 16, 2013
  5. Jharrod LaFonAug 16, 2013
  6. Jharrod LaFonAug 16, 2013
  7. Jeff KingAug 16, 2013
  8. Jharrod LaFonAug 19, 2013
  9. Junio C HamanoAug 19, 2013
  10. Jeff KingAug 19, 2013
  11. Thomas RastAug 16, 2013
  12. Junio C HamanoAug 19, 2013
  13. Jharrod LaFonAug 20, 2013

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.