about summary refs log tree commit
path: root/lib/Net/Cmd.pm
DateCommit message (Collapse)
2019-07-03Net::Cmd: call ->sysread and ->syswrite as OO methods
This seems required to support COMPRESS DEFLATE in NNTP in the next commit with minimal compatibility problems. The only potential compatibility problem is existing users of Net::NNTP won't be able to _blindly_ enable NNTP compression without auditing their existing code for uses for {syswrite,sysread}($cmd, ...). Other options I've attempted or considered for NNTP COMPRESS, but rejected: * tie won't work for deflating, since we need to syswrite to the original IO::Socket::* object (which may be IO::Socket::SSL) once we have a buffer of deflated data. * AFAIK, tie won't stack like PerlIO layers, either, and IO::Socket::SSL already uses tie. * using dup2 is wasteful, and won't work with TLS if we want to keep $self stable * open(my $fh, "<&=", $self) won't waste an FD, but still won't work with TLS for the same reason. * PerlIO::via won't work, since we rely on sysread/syswrite and that bypasses IO layers. So a future commit will provide ->syswrite and ->sysread to the NNTP class once it's compressed, and we can rely on SUPER::{sysread,syswrite} to make the underlying read, write, SSL_read, or SSL_write calls.
2019-07-02Net::Cmd: fix ->getline if SSL_read overreads read-early
sysread may call SSL_read, and SSL_read may buffer extra data in userspace which can be returned via sysread without making another read(2) syscall. This makes it it possible for select() to block indefinitely since select() only knows about buffers in the kernel, not userspace. This problem was exposed by a forthcoming patch to support NNTP compression, but it is theoretically possible to trigger with use of TLS alone, especially if compression is done by the TLS layer. Fortunately for existing users, TLS compression isn't widely used anymore because of CRIME and other vulnerabilities. So, flip the socket to non-blocking, perform the sysread, using select() to wait only if the kernel requires it, and reset the original blocking state of the socket when done to maintain compatibility with existing users. Thread-safety with flipping the O_NONBLOCK flag like this should not be a concern, because any application sharing connected TCP sockets across threads is buggy, anyways.
2019-07-02Net::Cmd: append directly to partial buf on sysread
sysread allow an offset argument to insert new data at a certain place, use it to simplify our code, slightly.
2017-12-15Use L<> rather than F<> for email addresses
2017-11-14Bump version
2016-10-27Simplify AUTHOR/copyright notices
2016-08-30Bump copyright dates for files changed this year
2016-08-01Bump version
2016-07-28Remove the default Net::Cmd::timeout()
This accidentally overrode the timeout() in Net::FTP's $IOCLASS. Instead, we now document that timeout() needs to be provided by the Net::Cmd sub-class (normally by inheriting from IO::Socket::INET or similar (which in turn inherit from IO::Socket, which provides timeout()), which most users seem to do anyway). Similarly, document that close() most also be provided (normally by inheriting from IO::Handle, which IO::Socket::INET or similar also do, via IO::Socket). This fixes CPAN RT#116345. Thanks to ppisar@redhat.com for the analysis.
2016-07-19Bump version
2016-07-07Provide (and document) a default Net::Cmd::timeout()
Previuosly, subclasses were required to provide a timeout() function, but this was not documented anywhere! Fixes CPAN RT#110978.
2016-01-05Bump version
2015-12-27Fix _set_status_closed() calls following commit 852982580b
2015-12-26Fix typo
2015-12-25Make other syswrites use _syswrite_with_timeout
Two other methods in Net::Cmd did syswrite() calls, both without a loop or timeout. This replaces those with a call to the new, common _syswrite_with_timeout() method, which does both correctly and restarts after EINTR.
2015-12-25Refactor syswrite with timeout
2015-09-01Bump version
2015-07-16Fix Net::Cmd::datasend() for octets stored in an upgraded string
The data passed to datasend() should already be encoded, but it can sometimes happen that the string holding the octets gets accidentally upgraded and it was wrong for datasend() to treat it differently in that case. Fixes CPAN RT#104433. Many thanks to Ricardo and Aristotle for their help on the ticket.
2015-07-08Bump version
2015-03-24Add licence files; clarify licence statements
2015-01-20Bump version
2014-12-09Bump version
2014-11-28Bump version
2014-10-11Bump version
2014-10-09Bump version
2014-10-09Bump version
2014-10-08Synchronize all $VERSIONs to the distribution's version number
Bump that to 3.00 so that no $VERSIONs end up going backwards.
2014-10-07Fix a warning introduced by the previous commit
"Use of uninitialized value in join or string at lib/Net/Cmd.pm line 158."
2014-10-07Improve code()/message() initialization and error handling in Net::Cmd
Amongst other things, this fixes a problem of obsolete error codes being returned after connection failure. Patch by Tom Metro <tmetro@cpan.org> on CPAN RT#14875 with minor changes by the committer to apply the patch to the current source.
2014-06-11Add optional POD coverage testing
2014-06-05Update copyright and fix POD
2014-06-04Make code Perl::Critic clean
2014-06-04Use 5.008001, strict and warnings throughout
2014-06-04We require perl-5.8.1 or higher now
2014-06-03Moved Net/*.pm into lib/Net/ sub-directory within distribution