ftp(1) from vendor/tnftp always tried the following for
every TCP connection:
1. Get the current buffer length of SO_SNDBUF and SO_RCVBUF
by getsockopt(2).
2. Invoke setsockopt(2) to set them to the same values
after checking if they are in a range between 8 KiB to 8 MiB.
This behavior broke dynamic buffer sizing enabled by
default (net.inet.tcp.{recv,send}buf_auto sysctls) and
led to a very poor transfer rate. The fetch(1) utility
does not have this problem.
This change prevents SO_SNDBUF and SO_RCVBUF from configuring
when the buffer auto-sizing is enabled unless the buffer sizes are
explicitly specified.
PR: 240827
Spotted by: Yuichiro NAITO
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D23732
contrib/tnftp/src/ftp.c:2067:11: error: implicit conversion from 'int'
to 'char' changes value from 255 to -1 [-Werror,-Wconstant-conversion]
buf[0] = IAC;
~ ^~~
/usr/include/arpa/telnet.h:39:13: note: expanded from macro 'IAC'
#define IAC 255 /* interpret as command: */
^~~
contrib/tnftp/src/ftp.c:2068:11: error: implicit conversion from 'int'
to 'char' changes value from 244 to -12 [-Werror,-Wconstant-conversion]
buf[1] = IP;
~ ^~
/usr/include/arpa/telnet.h:50:12: note: expanded from macro 'IP'
#define IP 244 /* interrupt process--permanently */
^~~
Use an unsigned char buffer instead.
MFC after: 1 week
The NetBSD Foundation states "Third parties are encouraged to change the
license on any files which have a 4-clause license contributed to the
NetBSD Foundation to a 2-clause license."
This change removes clauses 3 and 4 from copyright / license blocks that
list The NetBSD Foundation as the only copyright holder.
Sponsored by: The FreeBSD Foundation
socket is used. The previous code structure assumed that AF_INET sockets
were always available, which is an invalid assumption on IPv6-only systems.
This merges the fololowing revisions from NetBSD:
src/usr.bin/ftp/main.c 1.120
src/usr.bin/ftp/util.c 1.156
PR: bin/162661
Tested by: bz
Obtained from: NetBSD
MFC after: 1 week