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:
Daniel Stenberg 2025-03-14 17:30:09 +01:00
parent 5b6d3291b5
commit 7d679f9ab6
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
2 changed files with 7 additions and 11 deletions

View File

@ -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);

View File

@ -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];
};
/**