]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
http: remove a HTTP method size restriction
authorDaniel Stenberg <daniel@haxx.se>
Fri, 14 Mar 2025 16:30:09 +0000 (17:30 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 14 Mar 2025 19:10:09 +0000 (20:10 +0100)
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

lib/http.c
lib/http.h

index 5256ee7ead238b78e91f6a476b231ff7896f902e..03d1959e29aea519d2c3dbc3d254f023ddd554fd 100644 (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);
index 66abdbd20147a8f806f7220f9d4c83de9be89d52..ba7a121d094f56cdfb28c412cf866228fa06d19f 100644 (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];
 };
 
 /**