From: Daniel Stenberg Date: Fri, 14 Feb 2025 07:46:26 +0000 (+0100) Subject: strparse: make Curl_str_number() return error for no digits X-Git-Tag: curl-8_13_0~480 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=130b6891c8f388180d341845030a5db11fa06e7b;p=thirdparty%2Fcurl.git strparse: make Curl_str_number() return error for no digits Closes #16319 --- diff --git a/lib/strparse.c b/lib/strparse.c index b43b5415af..c540148c9a 100644 --- a/lib/strparse.c +++ b/lib/strparse.c @@ -110,7 +110,9 @@ int Curl_str_number(const char **linep, size_t *nump, size_t max) size_t num = 0; DEBUGASSERT(linep && *linep && nump); *nump = 0; - while(ISDIGIT(**linep)) { + if(!ISDIGIT(**linep)) + return STRE_NO_NUM; + do { int n = **linep - '0'; if(num > ((SIZE_T_MAX - n) / 10)) return STRE_OVERFLOW; @@ -118,7 +120,7 @@ int Curl_str_number(const char **linep, size_t *nump, size_t max) if(num > max) return STRE_BIG; /** too big */ (*linep)++; - } + } while(ISDIGIT(**linep)); *nump = num; return STRE_OK; } diff --git a/lib/strparse.h b/lib/strparse.h index dfae898f5b..77171f59a1 100644 --- a/lib/strparse.h +++ b/lib/strparse.h @@ -33,6 +33,7 @@ #define STRE_BYTE 5 #define STRE_NEWLINE 6 #define STRE_OVERFLOW 7 +#define STRE_NO_NUM 8 struct Curl_str { const char *str;