Skip to content

Commit

Permalink
remote-curl: fix large pushes with GSSAPI
Browse files Browse the repository at this point in the history
Due to an interaction between the way libcurl handles GSSAPI
authentication over HTTP and the way git uses libcurl, large
pushes (those over http.postBuffer bytes) would fail due to
an authentication failure requiring a rewind of the curl
buffer.  Such a rewind was not possible because the data did
not fit into the entire buffer.

Enable the use of the Expect: 100-continue header for large
requests where the server offers GSSAPI authentication to
avoid this issue, since the request would otherwise fail.
This allows git to get the authentication data right before
sending the pack contents.  Existing cases where pushes
would succeed, including small requests using GSSAPI, still
disable the use of 100 Continue, as it causes problems for
some remote HTTP implementations (servers and proxies).

Signed-off-by: Brian M. Carlson <sandals@crustytoothpaste.net>
Signed-off-by: Jeff King <peff@peff.net>
  • Loading branch information
Brian M. Carlson authored and Junio C Hamano committed Oct 31, 2013
1 parent 3a347ed commit c80d96c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions remote-curl.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ static int post_rpc(struct rpc_state *rpc)
char *gzip_body = NULL;
size_t gzip_size = 0;
int err, large_request = 0;
int needs_100_continue = 0;

/* Try to load the entire request, if we can fit it into the
* allocated buffer space we can use HTTP/1.0 and avoid the
Expand All @@ -446,16 +447,22 @@ static int post_rpc(struct rpc_state *rpc)
}

if (large_request) {
struct slot_results results;

do {
err = probe_rpc(rpc, NULL);
err = probe_rpc(rpc, &results);
} while (err == HTTP_REAUTH);
if (err != HTTP_OK)
return -1;

if (results.auth_avail & CURLAUTH_GSSNEGOTIATE)
needs_100_continue = 1;
}

headers = curl_slist_append(headers, rpc->hdr_content_type);
headers = curl_slist_append(headers, rpc->hdr_accept);
headers = curl_slist_append(headers, "Expect:");
headers = curl_slist_append(headers, needs_100_continue ?
"Expect: 100-continue" : "Expect:");

retry:
slot = get_active_slot();
Expand Down

0 comments on commit c80d96c

Please sign in to comment.