summaryrefslogtreecommitdiff
path: root/builtin-fetch.c
diff options
context:
space:
mode:
authorAndreas Ericsson <ae@op5.se>2009-04-17 10:20:11 +0200
committerJunio C Hamano <gitster@pobox.com>2009-04-21 00:05:21 -0700
commit47abd85ba06ed7209d1caa3e5ac7cc6b232bece4 (patch)
treeb8d5bde85778454775769c6d5cfa680cb9615916 /builtin-fetch.c
parent66996ecc28f001d3dcc73090717bb8c6e47c0d75 (diff)
downloadgit-47abd85ba06ed7209d1caa3e5ac7cc6b232bece4.tar.gz
fetch: Strip usernames from url's before storing them
When pulling from a remote, the full URL including username is by default added to the commit message. Since it adds very little value but could be used by malicious people to glean valid usernames (with matching hostnames), we're far better off just stripping the username before storing the remote URL locally. Note that this patch has no lasting visible effect when "git pull" does not create a merge commit. It simply alters what gets written to .git/FETCH_HEAD, which is used by "git merge" to automagically create its messages. Signed-off-by: Andreas Ericsson <ae@op5.se> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-fetch.c')
-rw-r--r--builtin-fetch.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/builtin-fetch.c b/builtin-fetch.c
index 3c998ea740..0bb290bf2f 100644
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
@@ -289,7 +289,7 @@ static int update_local_ref(struct ref *ref,
}
}
-static int store_updated_refs(const char *url, const char *remote_name,
+static int store_updated_refs(const char *raw_url, const char *remote_name,
struct ref *ref_map)
{
FILE *fp;
@@ -298,11 +298,13 @@ static int store_updated_refs(const char *url, const char *remote_name,
char note[1024];
const char *what, *kind;
struct ref *rm;
- char *filename = git_path("FETCH_HEAD");
+ char *url, *filename = git_path("FETCH_HEAD");
fp = fopen(filename, "a");
if (!fp)
return error("cannot open %s: %s\n", filename, strerror(errno));
+
+ url = transport_anonymize_url(raw_url);
for (rm = ref_map; rm; rm = rm->next) {
struct ref *ref = NULL;
@@ -376,6 +378,7 @@ static int store_updated_refs(const char *url, const char *remote_name,
fprintf(stderr, " %s\n", note);
}
}
+ free(url);
fclose(fp);
if (rc & 2)
error("some local refs could not be updated; try running\n"