mirror of
https://github.com/curl/curl.git
synced 2026-08-25 08:03:34 +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
|
|
@ -50,9 +50,12 @@
|
|||
#include "ftp.h"
|
||||
#include "ftplistparser.h"
|
||||
#include "curl_fnmatch.h"
|
||||
#include "curl_memory.h"
|
||||
#include "multiif.h"
|
||||
/* The last #include file should be: */
|
||||
#include "strparse.h"
|
||||
|
||||
/* The last 3 #include files should be in this order */
|
||||
#include "curl_printf.h"
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
typedef enum {
|
||||
|
|
@ -543,13 +546,13 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
|
|||
case PL_UNIX_HLINKS_NUMBER:
|
||||
parser->item_length ++;
|
||||
if(c == ' ') {
|
||||
char *p;
|
||||
long int hlinks;
|
||||
const char *p = &mem[parser->item_offset];
|
||||
size_t hlinks;
|
||||
mem[parser->item_offset + parser->item_length - 1] = 0;
|
||||
hlinks = strtol(mem + parser->item_offset, &p, 10);
|
||||
if(p[0] == '\0' && hlinks != LONG_MAX && hlinks != LONG_MIN) {
|
||||
|
||||
if(!Curl_str_number(&p, &hlinks, LONG_MAX)) {
|
||||
parser->file_data->info.flags |= CURLFINFOFLAG_KNOWN_HLINKCOUNT;
|
||||
parser->file_data->info.hardlinks = hlinks;
|
||||
parser->file_data->info.hardlinks = (long)hlinks;
|
||||
}
|
||||
parser->item_length = 0;
|
||||
parser->item_offset = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue