src: replace strto[u][ld] with curlx_str_ parsers

- Better error handling (no errno mess), better limit checks.

- Also removed all uses of curlx_strtoofft()

Closes #16634
This commit is contained in:
Daniel Stenberg 2025-03-09 12:49:24 +01:00
parent f3b599a7e2
commit 8dca3b0656
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
12 changed files with 150 additions and 205 deletions

View file

@ -448,25 +448,19 @@ ParameterError setvariable(struct GlobalConfig *global,
clen = strlen(ge);
}
}
if(*line == '[') {
if(*line == '[' && ISDIGIT(line[1])) {
/* is there a byte range specified? [num-num] */
if(ISDIGIT(line[1])) {
char *endp;
if(curlx_strtoofft(&line[1], &endp, 10, &startoffset) || (*endp != '-'))
return PARAM_VAR_SYNTAX;
else {
char *p = endp + 1; /* pass the '-' */
if(*p != ']') {
if(curlx_strtoofft(p, &endp, 10, &endoffset) || (*endp != ']'))
return PARAM_VAR_SYNTAX;
line = &endp[1]; /* pass the ']' */
}
else
line = &p[1]; /* pass the ']' */
}
if(startoffset > endoffset)
line++;
if(curlx_str_number(&line, &startoffset, CURL_OFF_T_MAX) ||
curlx_str_single(&line, '-'))
return PARAM_VAR_SYNTAX;
if(curlx_str_single(&line, ']')) {
if(curlx_str_number(&line, &endoffset, CURL_OFF_T_MAX) ||
curlx_str_single(&line, ']'))
return PARAM_VAR_SYNTAX;
}
if(startoffset > endoffset)
return PARAM_VAR_SYNTAX;
}
if(content)
;