← Commit list

6c0338115a

Daniel Stenberg
Daniel Stenberg
2025-10-09
SUCCESS Duration: 162s

Subject

ftp: simplify the 150/126 size scanner

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

lib/ftp.c+11 -22
@@ -2496,30 +2496,19 @@ static CURLcode ftp_state_get_resp(struct Curl_easy *data,
* those cases only confuses us.
*
* Example D above makes this parsing a little tricky */
- const char *bytes;
- char *buf = curlx_dyn_ptr(&ftpc->pp.recvbuf);
- bytes = strstr(buf, " bytes");
- if(bytes) {
- long in = (long)(--bytes-buf);
- /* this is a hint there is size information in there! ;-) */
- while(--in) {
- /* scan for the left parenthesis and break there */
- if('(' == *bytes)
- break;
- /* skip only digits */
- if(!ISDIGIT(*bytes)) {
- bytes = NULL;
+ size_t len = curlx_dyn_len(&ftpc->pp.recvbuf);
+ if(len >= 7) { /* "1 bytes" is 7 characters */
+ size_t i;
+ for(i = 0; i < len - 7; i++) {
+ curl_off_t what;
+ char *buf = curlx_dyn_ptr(&ftpc->pp.recvbuf);
+ const char *c = &buf[i];
+ if(!curlx_str_number(&c, &what, CURL_OFF_T_MAX) &&
+ !curlx_str_single(&c, ' ') &&
+ !strncmp(c, "bytes", 5)) {
+ size = what;
break;
}
- /* one more estep backwards */
- bytes--;
- }
- /* if we have nothing but digits: */
- if(bytes) {
- ++bytes;
- /* get the number! */
- if(curlx_str_number(&bytes, &size, CURL_OFF_T_MAX))
- size = 1;
}
}
}