Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
submodule--helper: fix potential NULL-dereference
author
Stefan Beller
<sbeller@google.com>
Thu, 31 Mar 2016 21:04:37 +0000
(14:04 -0700)
committer
Junio C Hamano
<gitster@pobox.com>
Thu, 31 Mar 2016 22:19:01 +0000
(15:19 -0700)
Don't dereference NULL 'path' if it was never assigned. Also
protect against an empty --path argument.
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/submodule--helper.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
3fea121
)
diff --git
a/builtin/submodule--helper.c
b/builtin/submodule--helper.c
index f4c3eff179b5f25e5d09c26348c107d0582455f2..4f0b0022eec10428774d4fad769987a0ddf42b50 100644
(file)
--- a/
builtin/submodule--helper.c
+++ b/
builtin/submodule--helper.c
@@
-194,6
+194,9
@@
static int module_clone(int argc, const char **argv, const char *prefix)
argc = parse_options(argc, argv, prefix, module_clone_options,
git_submodule_helper_usage, 0);
argc = parse_options(argc, argv, prefix, module_clone_options,
git_submodule_helper_usage, 0);
+ if (!path || !*path)
+ die(_("submodule--helper: unspecified or empty --path"));
+
strbuf_addf(&sb, "%s/modules/%s", get_git_dir(), name);
sm_gitdir = strbuf_detach(&sb, NULL);
strbuf_addf(&sb, "%s/modules/%s", get_git_dir(), name);
sm_gitdir = strbuf_detach(&sb, NULL);
@@
-215,10
+218,7
@@
static int module_clone(int argc, const char **argv, const char *prefix)
if (safe_create_leading_directories_const(path) < 0)
die(_("could not create directory '%s'"), path);
if (safe_create_leading_directories_const(path) < 0)
die(_("could not create directory '%s'"), path);
- if (path && *path)
- strbuf_addf(&sb, "%s/.git", path);
- else
- strbuf_addstr(&sb, ".git");
+ strbuf_addf(&sb, "%s/.git", path);
if (safe_create_leading_directories_const(sb.buf) < 0)
die(_("could not create leading directories of '%s'"), sb.buf);
if (safe_create_leading_directories_const(sb.buf) < 0)
die(_("could not create leading directories of '%s'"), sb.buf);