From 525da3e1eb5fc227e2af245bf3acae02b0627162 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 25 Oct 2010 15:49:42 -0400 Subject: [PATCH] Fix Content-Length when trying send more than 100GB of data (!) on an evhttp. --- http.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/http.c b/http.c index 162f955a..be2b12fe 100644 --- a/http.c +++ b/http.c @@ -386,8 +386,7 @@ evhttp_make_header_request(struct evhttp_connection *evcon, /* Add the content length on a post or put request if missing */ if ((req->type == EVHTTP_REQ_POST || req->type == EVHTTP_REQ_PUT) && evhttp_find_header(req->output_headers, "Content-Length") == NULL){ - /* XXX what if long is 64 bits? -NM */ - char size[12]; + char size[22]; evutil_snprintf(size, sizeof(size), "%ld", (long)evbuffer_get_length(req->output_buffer)); evhttp_add_header(req->output_headers, "Content-Length", size); @@ -451,7 +450,7 @@ evhttp_maybe_add_content_length_header(struct evkeyvalq *headers, { if (evhttp_find_header(headers, "Transfer-Encoding") == NULL && evhttp_find_header(headers, "Content-Length") == NULL) { - char len[12]; /* XXX what if long is 64 bits? -NM */ + char len[22]; evutil_snprintf(len, sizeof(len), "%ld", content_length); evhttp_add_header(headers, "Content-Length", len); }