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

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

From
Jeff King <peff@peff.net>
Date
Aug 16, 2013, 13:14 UTC
Message-ID
<20130816131406.GC20138@sigill.intra.peff.net>
In-Reply-To
<20130816130957.GB20138@sigill.intra.peff.net>
On Fri, Aug 16, 2013 at 09:09:58AM -0400, Jeff King wrote:
Show 13 quoted lines
> > > -	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;
> 
> I think this is also the wrong place to make the check, anyway. It is
> saying that all values of submodule.X.Y must be non-NULL. But that is
> not true. The submodule.X.fetchRecurseSubmodules option can be a
> boolean, and:
> 
>   [submodule "foo"]
>     fetchRecurseSubmodules
> 
> is perfectly valid (and is broken by this patch).
IOW, I think this is the right fix:
diff --git a/submodule.c b/submodule.c
index 3f0a3f9..c0f93c2 100644
--- a/submodule.c
+++ b/submodule.c
@@ -134,6 +134,9 @@ int parse_submodule_config_option(const char *var, const char *value)
 		return 0;
 
 	if (!strcmp(key, "path")) {
+		if (!value)
+			return config_error_nonbool(var);
+
 		config = unsorted_string_list_lookup(&config_name_for_path, value);
 		if (config)
 			free(config->util);
@@ -151,6 +154,9 @@ int parse_submodule_config_option(const char *var, const char *value)
 	} else if (!strcmp(key, "ignore")) {
 		char *name_cstr;
 
+		if (!value)
+			return config_error_nonbool(var);
+
 		if (strcmp(value, "untracked") && strcmp(value, "dirty") &&
 		    strcmp(value, "all") && strcmp(value, "none")) {
 			warning("Invalid parameter \"%s\" for config option \"submodule.%s.ignore\"", value, var);

And new options, as they are added, must decide whether they are boolean
or not (and check !value as appropriate).

-Peff
Previous: Jeff KingNext: Jharrod LaFon
Message 4 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.