mirror of
https://github.com/curl/curl.git
synced 2026-08-24 15:23:36 +03:00
lib: use Curl_str_number() for parsing decimal numbers
Instead of strtoul() and strtol() calls. Easier API with better integer overflow detection and built-in max check that now comes automatic everywhere this is used. Closes #16319
This commit is contained in:
parent
130b6891c8
commit
b696fc129b
16 changed files with 180 additions and 202 deletions
|
|
@ -83,6 +83,7 @@
|
|||
#include "share.h"
|
||||
#include "strdup.h"
|
||||
#include "version_win32.h"
|
||||
#include "strparse.h"
|
||||
|
||||
/* The last 3 #include files should be in this order */
|
||||
#include "curl_printf.h"
|
||||
|
|
@ -741,10 +742,9 @@ 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 */
|
||||
unsigned long scope_id = strtoul(scope_ptr, NULL, 10);
|
||||
if(scope_id > UINT_MAX)
|
||||
size_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;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue