aboutsummaryrefslogtreecommitdiffstats
path: root/remote-curl.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-04-23 22:07:45 -0700
committerJunio C Hamano <gitster@pobox.com>2017-04-23 22:07:45 -0700
commit4c01f67d9102942cc7f0a737de4c609a6ac1832e (patch)
treeb1e2e725ac7fb708dba5a732271d45d675ed5bfd /remote-curl.c
parent848d9a9bb7407cd3a2d45941f732b2ddc32588a7 (diff)
parent37ee680d9b90fe4c4fc5be4e14f17baf49f6ce59 (diff)
downloadgit-4c01f67d9102942cc7f0a737de4c609a6ac1832e.tar.gz
Merge branch 'dt/http-postbuffer-can-be-large'
Allow the http.postbuffer configuration variable to be set to a size that can be expressed in size_t, which can be larger than ulong on some platforms. * dt/http-postbuffer-can-be-large: http.postbuffer: allow full range of ssize_t values
Diffstat (limited to 'remote-curl.c')
-rw-r--r--remote-curl.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/remote-curl.c b/remote-curl.c
index d41fe16ff3..ece45993da 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -531,6 +531,12 @@ static int probe_rpc(struct rpc_state *rpc, struct slot_results *results)
return err;
}
+static curl_off_t xcurl_off_t(ssize_t len) {
+ if (len > maximum_signed_value_of_type(curl_off_t))
+ die("cannot handle pushes this big");
+ return (curl_off_t) len;
+}
+
static int post_rpc(struct rpc_state *rpc)
{
struct active_request_slot *slot;
@@ -614,7 +620,7 @@ retry:
* and we just need to send it.
*/
curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDS, gzip_body);
- curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDSIZE, gzip_size);
+ curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDSIZE_LARGE, xcurl_off_t(gzip_size));
} else if (use_gzip && 1024 < rpc->len) {
/* The client backend isn't giving us compressed data so
@@ -645,7 +651,7 @@ retry:
headers = curl_slist_append(headers, "Content-Encoding: gzip");
curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDS, gzip_body);
- curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDSIZE, gzip_size);
+ curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDSIZE_LARGE, xcurl_off_t(gzip_size));
if (options.verbosity > 1) {
fprintf(stderr, "POST %s (gzip %lu to %lu bytes)\n",
@@ -658,7 +664,7 @@ retry:
* more normal Content-Length approach.
*/
curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDS, rpc->buf);
- curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDSIZE, rpc->len);
+ curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDSIZE_LARGE, xcurl_off_t(rpc->len));
if (options.verbosity > 1) {
fprintf(stderr, "POST %s (%lu bytes)\n",
rpc->service_name, (unsigned long)rpc->len);