urlglob: only accept 255 globs

- using {} with single entries makes little sense
- when using {} sets with two entry lists, there can only be 64 to reach
  maximum number of URLs

Verify the max check in test 761
This commit is contained in:
Daniel Stenberg 2025-08-29 23:25:50 +02:00
parent 598078dcf8
commit 4a3ed6fc16
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 40 additions and 4 deletions

View file

@ -423,10 +423,13 @@ static CURLcode glob_parse(struct URLGlob *glob, const char *pattern,
if(++glob->size >= glob->palloc) {
struct URLPattern *np = NULL;
glob->palloc *= 2;
if(glob->size < 10000) /* avoid ridiculous amounts */
if(glob->size < 255) { /* avoid ridiculous amounts */
np = realloc(glob->pattern, glob->palloc * sizeof(struct URLPattern));
if(!np)
return globerror(glob, NULL, pos, CURLE_OUT_OF_MEMORY);
if(!np)
return globerror(glob, NULL, pos, CURLE_OUT_OF_MEMORY);
}
else
return globerror(glob, "too many {} sets", pos, CURLE_URL_MALFORMAT);
glob->pattern = np;
}
}