From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH] remote: check config validity before creating rewrite struct
Date: Fri, 11 Jan 2019 14:30:11 -0500 [thread overview]
Message-ID: <20190111193011.GA19839@sigill.intra.peff.net> (raw)
When parsing url.foo.insteadOf, we call make_rewrite() and only then
check to make sure the value is a string (and return an error if it
isn't). This isn't quite a leak, because the struct we allocate is part
of a global array, but it does leave a funny half-finished struct.
In practice, it doesn't make much difference because we exit soon after
due to the config error anyway. But let's flip the order here to avoid
leaving a trap for somebody in the future.
Signed-off-by: Jeff King <peff@peff.net>
---
This was a minor cleanup I mentioned in:
https://public-inbox.org/git/20181122173109.GI28192@sigill.intra.peff.net/
but didn't get picked up.
remote.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/remote.c b/remote.c
index 670dd44813..9cc3b07d21 100644
--- a/remote.c
+++ b/remote.c
@@ -337,14 +337,14 @@ static int handle_config(const char *key, const char *value, void *cb)
if (!name)
return 0;
if (!strcmp(subkey, "insteadof")) {
- rewrite = make_rewrite(&rewrites, name, namelen);
if (!value)
return config_error_nonbool(key);
+ rewrite = make_rewrite(&rewrites, name, namelen);
add_instead_of(rewrite, xstrdup(value));
} else if (!strcmp(subkey, "pushinsteadof")) {
- rewrite = make_rewrite(&rewrites_push, name, namelen);
if (!value)
return config_error_nonbool(key);
+ rewrite = make_rewrite(&rewrites_push, name, namelen);
add_instead_of(rewrite, xstrdup(value));
}
}
--
2.20.1.651.g2d41a78c67
next reply other threads:[~2019-01-11 19:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-11 19:30 Jeff King [this message]
2019-01-12 2:36 ` [PATCH] remote: check config validity before creating rewrite struct Junio C Hamano
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190111193011.GA19839@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).