From: Marco Scarpetta Date: Wed, 1 Feb 2017 10:29:08 +0000 (+0100) Subject: Fix parsing of directories listing on a specific ftp server X-Git-Tag: archive/raspbian/5.97.0-1+rpi1~1^2^2^2^2~4 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=fe50045f2133208822d0b98b59a866ecf8f429ac;p=kio.git Fix parsing of directories listing on a specific ftp server Directories listing on ftp servers like ftp://ftp-dee.poliba.it/ are now parsed correctly. BUG: 375610 REVIEW: 129905 FIXED-IN: 5.31 Gbp-Pq: Name Fix-parsing-of-directories-listing-on-a-specific-ftp-serv.patch --- diff --git a/src/ioslaves/ftp/ftp.cpp b/src/ioslaves/ftp/ftp.cpp index 2e129fc..e41c764 100644 --- a/src/ioslaves/ftp/ftp.cpp +++ b/src/ioslaves/ftp/ftp.cpp @@ -1669,24 +1669,35 @@ bool Ftp::ftpReadDir(FtpEntry &de) } } + // This is needed for ftp servers with a directory listing like this (#375610): + // drwxr-xr-x folder 0 Mar 15 15:50 directory_name + if (strcmp(p_junk, "folder") == 0) { + p_date_1 = p_group; + p_date_2 = p_size; + p_size = p_owner; + p_group = nullptr; + p_owner = nullptr; + } // Check whether the size we just read was really the size // or a month (this happens when the server lists no group) // Used to be the case on sunsite.uio.no, but not anymore // This is needed for the Netware case, too. - if (!isdigit(*p_size)) { + else if (!isdigit(*p_size)) { p_date_1 = p_size; + p_date_2 = strtok(nullptr, " "); p_size = p_group; p_group = 0; qCDebug(KIO_FTP) << "Size didn't have a digit -> size=" << p_size << " date_1=" << p_date_1; } else { - p_date_1 = strtok(NULL, " "); + p_date_1 = strtok(nullptr, " "); + p_date_2 = strtok(nullptr, " "); qCDebug(KIO_FTP) << "Size has a digit -> ok. p_date_1=" << p_date_1; } - if (p_date_1 != 0 && - (p_date_2 = strtok(NULL, " ")) != 0 && - (p_date_3 = strtok(NULL, " ")) != 0 && - (p_name = strtok(NULL, "\r\n")) != 0) { + if (p_date_1 != nullptr && + p_date_2 != nullptr && + (p_date_3 = strtok(nullptr, " ")) != nullptr && + (p_name = strtok(nullptr, "\r\n")) != nullptr) { { QByteArray tmp(p_name); if (p_access[0] == 'l') {