lavv17 / lftp

sophisticated command line file transfer program (ftp, http, sftp, fish, torrent)
http://lftp.yar.ru
GNU General Public License v3.0
1.08k stars 159 forks source link

lftp hangs when using ftps on AIX #672

Closed kadler closed 1 year ago

kadler commented 1 year ago
-bash-5.1$ lftp -d ftps://test.rebex.net
---- Resolving host address...
---- 1 address found: 195.144.107.198              
lftp test.rebex.net:~> ls
---- Connecting to test.rebex.net (195.144.107.198) port 990
Certificate depth: 2; subject: /C=US/O=Internet Security Research Group/CN=ISRG Root X1; issuer: /C=US/O=Internet Security Research Group/CN=ISRG Root X1
Certificate depth: 1; subject: /C=US/O=Let's Encrypt/CN=R3; issuer: /C=US/O=Internet Security Research Group/CN=ISRG Root X1
Certificate depth: 0; subject: /CN=test.rebex.net; issuer: /C=US/O=Let's Encrypt/CN=R3
Certificate verification: subjectAltName: ‘test.rebex.net’ matched
<--- 220 Microsoft FTP Service
---> FEAT
`ls' at 0 [FEAT negotiation...]

The code seems to be calling select over and over, but never continues. Debugging a bit, I found that the code is calling select with nfds=7, but both in and out have no fd bits set. This is because the enum in PollVec.h is used to set these bits in PollVec::AddFd and PollVec::FDReady, however the only code which actually uses these enum are in PollVec.cc. Instead, the rest of the code uses POLLIN and POLLOUT and while the enum values are defined match those the values of POLLIN and POLLOUT on Linux, FreeBSD, macOS, and other Unix systems, on AIX POLLIN is 1, POLLOUT is 2, and POLLPRI is 4. This prevents the rest of the code from checking when a file descriptor is ready for output and hangs forever.