summaryrefslogtreecommitdiff
path: root/http-walker.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-03-17 20:50:26 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-03-17 20:50:26 (GMT)
commit2af882be0181ee29aa3a4fb3181b94e9bca53c51 (patch)
tree272c989fa1da86097b72e11a61079623515f459e /http-walker.c
parentf6c64c648ade843b44d517b2de41b8b882f112c0 (diff)
parentd61434ae813cc86a1a87d05cc61e36e87b0e20a9 (diff)
downloadgit-2af882be0181ee29aa3a4fb3181b94e9bca53c51.zip
git-2af882be0181ee29aa3a4fb3181b94e9bca53c51.tar.gz
git-2af882be0181ee29aa3a4fb3181b94e9bca53c51.tar.bz2
Merge branch 'jk/http-walker-buffer-underflow-fix'
"Dumb http" transport used to misparse a nonsense http-alternates response, which has been fixed. * jk/http-walker-buffer-underflow-fix: http-walker: fix buffer underflow processing remote alternates
Diffstat (limited to 'http-walker.c')
-rw-r--r--http-walker.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/http-walker.c b/http-walker.c
index ab7d553..ee049cb 100644
--- a/http-walker.c
+++ b/http-walker.c
@@ -301,13 +301,16 @@ static void process_alternates_response(void *callback_data)
okay = 1;
}
}
- /* skip "objects\n" at end */
if (okay) {
struct strbuf target = STRBUF_INIT;
strbuf_add(&target, base, serverlen);
- strbuf_add(&target, data + i, posn - i - 7);
-
- if (is_alternate_allowed(target.buf)) {
+ strbuf_add(&target, data + i, posn - i);
+ if (!strbuf_strip_suffix(&target, "objects")) {
+ warning("ignoring alternate that does"
+ " not end in 'objects': %s",
+ target.buf);
+ strbuf_release(&target);
+ } else if (is_alternate_allowed(target.buf)) {
warning("adding alternate object store: %s",
target.buf);
newalt = xmalloc(sizeof(*newalt));