Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-9]: src/usr.bin/ftp Pull up following revision(s) (requested by l...
details: https://anonhg.NetBSD.org/src/rev/8e5cee9c4c4f
branches: netbsd-9
changeset: 983933:8e5cee9c4c4f
user: martin <martin%NetBSD.org@localhost>
date: Mon Jun 14 11:57:39 2021 +0000
description:
Pull up following revision(s) (requested by lukem in ticket #1295):
usr.bin/ftp/ssl.c: revision 1.10
usr.bin/ftp/ssl.h: revision 1.5
usr.bin/ftp/version.h: revision 1.93
usr.bin/ftp/Makefile: revision 1.39
use fetch_*() for I/O with SMALLPROG / !WITH_SSL builds
Adapt the SMALLPROG / -UWITH_SSL build to also use the fetch_*()
methods from ssl.c, instead of using stdio, as stdio isn't robust
when using interruptable signals.
Disable ssl-specific support in the fetch_*() methods if WITH_SSL
isn't defined, so SMALLPROG still doesn't have ssl support (as expected).
The resulting SMALLPROG binary is slightly larger than before
(e.g., 157KiB vs 153KiB on amd64).
Set version to 20210603 for this fix and the SO_KEEPALIVE fix for PR 56129.
PR install/56219
diffstat:
usr.bin/ftp/Makefile | 4 ++--
usr.bin/ftp/ssl.c | 29 +++++++++++++++++++++++++----
usr.bin/ftp/ssl.h | 23 ++---------------------
usr.bin/ftp/version.h | 4 ++--
4 files changed, 31 insertions(+), 29 deletions(-)
diffs (211 lines):
diff -r 4f031492a166 -r 8e5cee9c4c4f usr.bin/ftp/Makefile
--- a/usr.bin/ftp/Makefile Mon Jun 14 11:52:52 2021 +0000
+++ b/usr.bin/ftp/Makefile Mon Jun 14 11:57:39 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.37 2017/05/21 15:28:43 riastradh Exp $
+# $NetBSD: Makefile,v 1.37.12.1 2021/06/14 11:57:39 martin Exp $
# from: @(#)Makefile 8.2 (Berkeley) 4/3/94
.include <bsd.own.mk>
@@ -8,6 +8,7 @@
PROG= ftp
SRCS= cmds.c cmdtab.c complete.c domacro.c fetch.c ftp.c main.c \
progressbar.c ruserpass.c util.c
+SRCS+= ssl.c
# Uncomment the following to provide defaults for gate-ftp operation
#
@@ -19,7 +20,6 @@
LDADD+= -ledit -lterminfo
DPADD+= ${LIBEDIT} ${LIBTERMINFO}
CPPFLAGS+= -DWITH_SSL
-SRCS+=ssl.c
LDADD+= -lssl -lcrypto
DPADD+= ${LIBSSL} ${LIBCRYPTO}
.endif
diff -r 4f031492a166 -r 8e5cee9c4c4f usr.bin/ftp/ssl.c
--- a/usr.bin/ftp/ssl.c Mon Jun 14 11:52:52 2021 +0000
+++ b/usr.bin/ftp/ssl.c Mon Jun 14 11:57:39 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ssl.c,v 1.8.2.1 2021/01/29 20:58:19 martin Exp $ */
+/* $NetBSD: ssl.c,v 1.8.2.2 2021/06/14 11:57:39 martin Exp $ */
/*-
* Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
@@ -34,13 +34,17 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: ssl.c,v 1.8.2.1 2021/01/29 20:58:19 martin Exp $");
+__RCSID("$NetBSD: ssl.c,v 1.8.2.2 2021/06/14 11:57:39 martin Exp $");
#endif
+#include <errno.h>
+#include <fcntl.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <time.h>
#include <unistd.h>
-#include <string.h>
-#include <fcntl.h>
#include <sys/param.h>
#include <sys/select.h>
@@ -48,11 +52,14 @@
#include <netinet/tcp.h>
#include <netinet/in.h>
+
+#ifdef WITH_SSL
#include <openssl/crypto.h>
#include <openssl/x509.h>
#include <openssl/pem.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
+#endif
#include "ssl.h"
@@ -75,7 +82,9 @@
int issock;
int iserr;
int iseof;
+#ifdef WITH_SSL
SSL *ssl; /* SSL handle */
+#endif
};
/*
@@ -121,9 +130,11 @@
}
}
errno = 0;
+#ifdef WITH_SSL
if (conn->ssl != NULL)
len = SSL_write(conn->ssl, iov->iov_base, iov->iov_len);
else
+#endif
len = writev(fd, iov, iovcnt);
if (len == 0) {
/* we consider a short write a failure */
@@ -275,7 +286,9 @@
return 0;
fetch_flush(conn);
+#ifdef WITH_SSL
SSL_free(conn->ssl);
+#endif
close(conn->sd);
free(conn->cache.buf);
free(conn->buf);
@@ -287,6 +300,7 @@
#define FETCH_READ_WAIT -2
#define FETCH_READ_ERROR -1
+#ifdef WITH_SSL
static ssize_t
fetch_ssl_read(SSL *ssl, void *buf, size_t len)
{
@@ -305,6 +319,7 @@
return FETCH_READ_ERROR;
}
}
+#endif /* WITH_SSL */
static ssize_t
fetch_nonssl_read(int sd, void *buf, size_t len)
@@ -433,9 +448,11 @@
* In the non-SSL case, it may improve performance (very
* slightly) when reading small amounts of data.
*/
+#ifdef WITH_SSL
if (conn->ssl != NULL)
rlen = fetch_ssl_read(conn->ssl, buf, len);
else
+#endif
rlen = fetch_nonssl_read(conn->sd, buf, len);
switch (rlen) {
case 0:
@@ -564,6 +581,7 @@
return len;
}
+#ifdef WITH_SSL
void *
fetch_start_ssl(int sock, const char *servername)
{
@@ -624,10 +642,13 @@
return ssl;
}
+#endif /* WITH_SSL */
void
fetch_set_ssl(struct fetch_connect *conn, void *ssl)
{
+#ifdef WITH_SSL
conn->ssl = ssl;
+#endif
}
diff -r 4f031492a166 -r 8e5cee9c4c4f usr.bin/ftp/ssl.h
--- a/usr.bin/ftp/ssl.h Mon Jun 14 11:52:52 2021 +0000
+++ b/usr.bin/ftp/ssl.h Mon Jun 14 11:57:39 2021 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: ssl.h,v 1.4 2019/04/04 00:36:09 christos Exp $ */
+/* $NetBSD: ssl.h,v 1.4.2.1 2021/06/14 11:57:39 martin Exp $ */
/*-
- * Copyright (c) 2012 The NetBSD Foundation, Inc.
+ * Copyright (c) 2012-2021 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,7 +25,6 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifdef WITH_SSL
#define FETCH struct fetch_connect
struct fetch_connect;
@@ -43,21 +42,3 @@
int fetch_getline(struct fetch_connect *, char *, size_t, const char **);
void fetch_set_ssl(struct fetch_connect *, void *);
void *fetch_start_ssl(int, const char *);
-
-#else /* !WITH_SSL */
-
-#define FETCH FILE
-
-#define fetch_printf fprintf
-#define fetch_fileno fileno
-#define fetch_error ferror
-#define fetch_flush fflush
-#define fetch_open fopen
-#define fetch_fdopen fdopen
-#define fetch_close fclose
-#define fetch_read fread
-#define fetch_getln fgets
-#define fetch_getline get_line
-#define fetch_set_ssl(a, b)
-
-#endif /* !WITH_SSL */
diff -r 4f031492a166 -r 8e5cee9c4c4f usr.bin/ftp/version.h
--- a/usr.bin/ftp/version.h Mon Jun 14 11:52:52 2021 +0000
+++ b/usr.bin/ftp/version.h Mon Jun 14 11:57:39 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: version.h,v 1.87.18.2 2021/06/14 11:22:16 martin Exp $ */
+/* $NetBSD: version.h,v 1.87.18.3 2021/06/14 11:57:39 martin Exp $ */
/*-
* Copyright (c) 1999-2021 The NetBSD Foundation, Inc.
@@ -34,5 +34,5 @@
#endif
#ifndef FTP_VERSION
-#define FTP_VERSION "20200711"
+#define FTP_VERSION "20210603"
#endif
Home |
Main Index |
Thread Index |
Old Index