mirror of
https://github.com/curl/curl.git
synced 2026-08-26 07:33:31 +03:00
strparse: switch to curl_off_t as base data type
- add hex and octal parsers to the Curl_str_* family - make curlx_strtoofft use these parsers - remove all use of strtol() and strtoul() in library code - generally use Curl_str_* more than strtoofft, for stricter parsing - supports 64-bit universally, instead of 'long' which differs in size between platforms Extended the unit test 1664 to verify hex and octal parsing. Closes #16336
This commit is contained in:
parent
876db1070b
commit
b4538ec522
46 changed files with 538 additions and 497 deletions
|
|
@ -742,7 +742,7 @@ static CURLcode bindlocal(struct Curl_easy *data, struct connectdata *conn,
|
|||
Curl_printable_address. The latter returns only numeric scope
|
||||
IDs and the former returns none at all. So the scope ID, if
|
||||
present, is known to be numeric */
|
||||
size_t scope_id;
|
||||
curl_off_t scope_id;
|
||||
if(Curl_str_number((const char **)&scope_ptr, &scope_id, UINT_MAX))
|
||||
return CURLE_UNSUPPORTED_PROTOCOL;
|
||||
si6->sin6_scope_id = (unsigned int)scope_id;
|
||||
|
|
@ -974,28 +974,28 @@ static CURLcode cf_socket_ctx_init(struct cf_socket_ctx *ctx,
|
|||
|
||||
#ifdef DEBUGBUILD
|
||||
{
|
||||
char *p = getenv("CURL_DBG_SOCK_WBLOCK");
|
||||
const char *p = getenv("CURL_DBG_SOCK_WBLOCK");
|
||||
if(p) {
|
||||
long l = strtol(p, NULL, 10);
|
||||
if(l >= 0 && l <= 100)
|
||||
curl_off_t l;
|
||||
if(!Curl_str_number(&p, &l, 100))
|
||||
ctx->wblock_percent = (int)l;
|
||||
}
|
||||
p = getenv("CURL_DBG_SOCK_WPARTIAL");
|
||||
if(p) {
|
||||
long l = strtol(p, NULL, 10);
|
||||
if(l >= 0 && l <= 100)
|
||||
curl_off_t l;
|
||||
if(!Curl_str_number(&p, &l, 100))
|
||||
ctx->wpartial_percent = (int)l;
|
||||
}
|
||||
p = getenv("CURL_DBG_SOCK_RBLOCK");
|
||||
if(p) {
|
||||
long l = strtol(p, NULL, 10);
|
||||
if(l >= 0 && l <= 100)
|
||||
curl_off_t l;
|
||||
if(!Curl_str_number(&p, &l, 100))
|
||||
ctx->rblock_percent = (int)l;
|
||||
}
|
||||
p = getenv("CURL_DBG_SOCK_RMAX");
|
||||
if(p) {
|
||||
long l = strtol(p, NULL, 10);
|
||||
if(l >= 0)
|
||||
curl_off_t l;
|
||||
if(!Curl_str_number(&p, &l, SIZE_T_MAX))
|
||||
ctx->recv_max = (size_t)l;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue