diff options
author | Curl Upstream <curl-library@cool.haxx.se> | 2017-10-04 05:52:15 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-10-10 15:15:03 (GMT) |
commit | de7c21d677db1ddaeece03c19e13e448f4031511 (patch) | |
tree | f812bbd3771bd01de9f7cd91a557766605f6ed2c /lib/ftplistparser.c | |
parent | 06d6d6c4aee149cd6560b919ef6935ef0867d921 (diff) | |
download | CMake-de7c21d677db1ddaeece03c19e13e448f4031511.zip CMake-de7c21d677db1ddaeece03c19e13e448f4031511.tar.gz CMake-de7c21d677db1ddaeece03c19e13e448f4031511.tar.bz2 |
curl 2017-10-04 (3ea76790)
Code extracted from:
https://github.com/curl/curl.git
at commit 3ea76790571c1f7cf1bed34fabffd3cc20ad3dd3 (curl-7_56_0).
Diffstat (limited to 'lib/ftplistparser.c')
-rw-r--r-- | lib/ftplistparser.c | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/lib/ftplistparser.c b/lib/ftplistparser.c index 2acce31..b2a8c0f 100644 --- a/lib/ftplistparser.c +++ b/lib/ftplistparser.c @@ -421,7 +421,7 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb, else if(c == '\n') { finfo->b_data[parser->item_length - 1] = 0; if(strncmp("total ", finfo->b_data, 6) == 0) { - char *endptr = finfo->b_data+6; + char *endptr = finfo->b_data + 6; /* here we can deal with directory size, pass the leading white spaces and then the digits */ while(ISSPACE(*endptr)) @@ -609,16 +609,18 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb, char *p; curl_off_t fsize; finfo->b_data[parser->item_offset + parser->item_length - 1] = 0; - fsize = curlx_strtoofft(finfo->b_data+parser->item_offset, &p, 10); - if(p[0] == '\0' && fsize != CURL_OFF_T_MAX && - fsize != CURL_OFF_T_MIN) { - parser->file_data->info.flags |= CURLFINFOFLAG_KNOWN_SIZE; - parser->file_data->info.size = fsize; + if(!curlx_strtoofft(finfo->b_data + parser->item_offset, + &p, 10, &fsize)) { + if(p[0] == '\0' && fsize != CURL_OFF_T_MAX && + fsize != CURL_OFF_T_MIN) { + parser->file_data->info.flags |= CURLFINFOFLAG_KNOWN_SIZE; + parser->file_data->info.size = fsize; + } + parser->item_length = 0; + parser->item_offset = 0; + parser->state.UNIX.main = PL_UNIX_TIME; + parser->state.UNIX.sub.time = PL_UNIX_TIME_PREPART1; } - parser->item_length = 0; - parser->item_offset = 0; - parser->state.UNIX.main = PL_UNIX_TIME; - parser->state.UNIX.sub.time = PL_UNIX_TIME_PREPART1; } else if(!ISDIGIT(c)) { PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST); @@ -935,19 +937,9 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb, } else { char *endptr; - finfo->size = curlx_strtoofft(finfo->b_data + - parser->item_offset, - &endptr, 10); - if(!*endptr) { - if(finfo->size == CURL_OFF_T_MAX || - finfo->size == CURL_OFF_T_MIN) { - if(errno == ERANGE) { - PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST); - return bufflen; - } - } - } - else { + if(curlx_strtoofft(finfo->b_data + + parser->item_offset, + &endptr, 10, &finfo->size)) { PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST); return bufflen; } |