http: use strbufs instead of fixed buffers

We keep the names of incoming packs and objects in fixed
PATH_MAX-size buffers, and snprintf() into them. This is
unlikely to end up with truncated filenames, but it is
possible (especially on systems where PATH_MAX is shorter
than actual paths can be). Let's switch to using strbufs,
which makes the question go away entirely.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff King
2018-05-18 18:56:37 -07:00
committed by Junio C Hamano
parent 468165c1d8
commit 390c6cbc5e
2 changed files with 38 additions and 32 deletions

4
http.h
View File

@ -200,7 +200,7 @@ struct http_pack_request {
struct packed_git *target;
struct packed_git **lst;
FILE *packfile;
char tmpfile[PATH_MAX];
struct strbuf tmpfile;
struct active_request_slot *slot;
};
@ -212,7 +212,7 @@ extern void release_http_pack_request(struct http_pack_request *preq);
/* Helpers for fetching object */
struct http_object_request {
char *url;
char tmpfile[PATH_MAX];
struct strbuf tmpfile;
int localfile;
CURLcode curl_result;
char errorstr[CURL_ERROR_SIZE];