mirror of
https://github.com/curl/curl.git
synced 2026-07-31 09:18:03 +03:00
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:
parent
f3b599a7e2
commit
8dca3b0656
12 changed files with 150 additions and 205 deletions
26
src/var.c
26
src/var.c
|
|
@ -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)
|
||||
;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue