diff --git a/lib/http.c b/lib/http.c index 5256ee7ead..03d1959e29 100644 --- a/lib/http.c +++ b/lib/http.c @@ -4238,11 +4238,9 @@ CURLcode Curl_http_req_make(struct httpreq **preq, struct httpreq *req; CURLcode result = CURLE_OUT_OF_MEMORY; - DEBUGASSERT(method); - if(m_len + 1 > sizeof(req->method)) - return CURLE_BAD_FUNCTION_ARGUMENT; + DEBUGASSERT(method && m_len); - req = calloc(1, sizeof(*req)); + req = calloc(1, sizeof(*req) + m_len); if(!req) goto out; memcpy(req->method, method, m_len); @@ -4394,11 +4392,9 @@ CURLcode Curl_http_req_make2(struct httpreq **preq, CURLcode result = CURLE_OUT_OF_MEMORY; CURLUcode uc; - DEBUGASSERT(method); - if(m_len + 1 > sizeof(req->method)) - return CURLE_BAD_FUNCTION_ARGUMENT; + DEBUGASSERT(method && m_len); - req = calloc(1, sizeof(*req)); + req = calloc(1, sizeof(*req) + m_len); if(!req) goto out; memcpy(req->method, method, m_len); diff --git a/lib/http.h b/lib/http.h index 66abdbd201..ba7a121d09 100644 --- a/lib/http.h +++ b/lib/http.h @@ -218,12 +218,12 @@ CURLcode Curl_http_decode_status(int *pstatus, const char *s, size_t len); * All about a core HTTP request, excluding body and trailers */ struct httpreq { - char method[24]; + struct dynhds headers; + struct dynhds trailers; char *scheme; char *authority; char *path; - struct dynhds headers; - struct dynhds trailers; + char method[1]; }; /**