Created
August 16, 2013 02:03
-
-
Save jlafon/6246629 to your computer and use it in GitHub Desktop.
git patch for submodule seg fault
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
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. | |
--- | |
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")) { | |
-- | |
1.7.9.5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment