Skip to content

Commit c953cf9

Browse files
committed
Merge branch 'ew/http-alternates-as-redirects-warning' into maint
Recent versions of Git treats http alternates (used in dumb http transport) just like HTTP redirects and requires the client to enable following it, due to security concerns. But we forgot to give a warning when we decide not to honor the alternates. * ew/http-alternates-as-redirects-warning: http: release strbuf on disabled alternates http: inform about alternates-as-redirects behavior
2 parents bfee58c + 5cae73d commit c953cf9

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

http-walker.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ static int is_alternate_allowed(const char *url)
168168
};
169169
int i;
170170

171+
if (http_follow_config != HTTP_FOLLOW_ALWAYS) {
172+
warning("alternate disabled by http.followRedirects: %s", url);
173+
return 0;
174+
}
175+
171176
for (i = 0; i < ARRAY_SIZE(protocols); i++) {
172177
const char *end;
173178
if (skip_prefix(url, protocols[i], &end) &&
@@ -317,6 +322,8 @@ static void process_alternates_response(void *callback_data)
317322
while (tail->next != NULL)
318323
tail = tail->next;
319324
tail->next = newalt;
325+
} else {
326+
strbuf_release(&target);
320327
}
321328
}
322329
}
@@ -334,9 +341,6 @@ static void fetch_alternates(struct walker *walker, const char *base)
334341
struct alternates_request alt_req;
335342
struct walker_data *cdata = walker->data;
336343

337-
if (http_follow_config != HTTP_FOLLOW_ALWAYS)
338-
return;
339-
340344
/*
341345
* If another request has already started fetching alternates,
342346
* wait for them to arrive and return to processing this request's

0 commit comments

Comments
 (0)