Permalink
Browse files

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>
  • Loading branch information...
1 parent af3aec4 commit 3443db51a0f2a43061d4badc6a0065672386eae5 @peff peff committed with Feb 6, 2013
Showing with 1 addition and 0 deletions.
  1. +1 −0 http.c
View
1 http.c
@@ -841,6 +841,7 @@ static int http_request(const char *url, struct strbuf *type,
if (type) {
char *t;
+ strbuf_reset(type);
curl_easy_getinfo(slot->curl, CURLINFO_CONTENT_TYPE, &t);
if (t)
strbuf_addstr(type, t);

0 comments on commit 3443db5

Please sign in to comment.