http_request: reset "type" strbuf before adding
Callers may pass us a strbuf which we use to record the content-type of the response. However, we simply appended to it rather than overwriting its contents, meaning that cruft in the strbuf gave us a bogus type. E.g., the multiple requests triggered by http_request could yield a type like "text/plainapplication/x-git-receive-pack-advertisement". Reported-by: Michael Schubert <mschub@elegosoft.com> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Feb 6, 2013 at 05:39 UTC
3443db51a0f2a43061d4badc6a0065672386eae5
1 file changed
+1
http.c
+1
@@ -841,6 +841,7 @@ static int http_request(const char *url, struct strbuf *type,
841
842
if (type) {
843
char *t;
844
+ strbuf_reset(type);
845
curl_easy_getinfo(slot->curl, CURLINFO_CONTENT_TYPE, &t);
846
if (t)
847
strbuf_addstr(type, t);