]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
strparse: make curlx_str_until() accept zero for 'max'
authorDaniel Stenberg <daniel@haxx.se>
Wed, 13 May 2026 22:06:03 +0000 (00:06 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 15 May 2026 11:28:03 +0000 (13:28 +0200)
When asked to parse for a string with max zero bytes, it will always
return error and no longer trigger an assert. This saves the caller from
having to check for this condition.

Closes #21600

lib/curlx/strparse.c

index 3082a6740adcfffe59d6af02201820614ea9a40d..736f62050438723381a38886b6609acdae351567 100644 (file)
@@ -45,7 +45,7 @@ void curlx_str_trim(struct Curl_str *out, size_t len)
 }
 
 /* Get a word until the first DELIM or end of string. At least one byte long.
-   return non-zero on error */
+   return non-zero on error. If 'max' is zero, it will always return error. */
 int curlx_str_until(const char **linep, struct Curl_str *out,
                     const size_t max, char delim)
 {
@@ -54,7 +54,6 @@ int curlx_str_until(const char **linep, struct Curl_str *out,
   DEBUGASSERT(linep);
   DEBUGASSERT(*linep);
   DEBUGASSERT(out);
-  DEBUGASSERT(max);
   DEBUGASSERT(delim);
   s = *linep;