mirror of
https://github.com/curl/curl.git
synced 2025-04-12 16:20:35 +08:00
http: remove a HTTP method size restriction
By allocating the method string as part of the struct, the previous fixed size limit (23 bytes) can be avoided. It would previously make "curl -X [long string]" work against http://localhost but fail against https://curl.se with no clear error message. Closes #16729
This commit is contained in:
parent
5b6d3291b5
commit
7d679f9ab6
12
lib/http.c
12
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);
|
||||
|
@ -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];
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user