From 31cc6c9ad1f37c5ef7aa0cd691e6e819e9abdbaa Mon Sep 17 00:00:00 2001 From: Lain Iwakura Date: Tue, 30 Dec 2025 00:58:09 +0300 Subject: fix(ssl): partially fix ssl --- cookie.c | 2 +- fetch.c | 38 +++++++++++++++++++------------------- ftp_var.h | 6 +++--- main.c | 18 +++++++++--------- tls_compat.c | 2 +- 5 files changed, 33 insertions(+), 33 deletions(-) diff --git a/cookie.c b/cookie.c index b5f5beb..5579d71 100644 --- a/cookie.c +++ b/cookie.c @@ -16,7 +16,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#ifndef NOSSL +#if !defined(NOSSL) || !NOSSL #include #include diff --git a/fetch.c b/fetch.c index 47161b0..5c3006c 100644 --- a/fetch.c +++ b/fetch.c @@ -87,10 +87,10 @@ static const char *sockerror(tls_t); #else static int ftp_printf(FILE *, const char *, ...); #endif /* SMALL */ -#ifndef NOSSL -static int proxy_connect(int, char *, char *); -static int stdio_tls_write_wrapper(void *, const char *, int); -static int stdio_tls_read_wrapper(void *, char *, int); +#if !defined(NOSSL) || !NOSSL + static int proxy_connect(int, char *, char *); + static int stdio_tls_write_wrapper(void *, const char *, int); + static int stdio_tls_read_wrapper(void *, char *, int); #endif /* !NOSSL */ #define FTP_URL "ftp://" /* ftp URL prefix */ @@ -328,7 +328,7 @@ url_get(const char *origline, const char *proxyenv, const char *outfile, int las ssize_t len, wlen; size_t bufsize; char *proxyhost = NULL; -#ifndef NOSSL +#if !defined(NOSSL) || !NOSSL char *sslpath = NULL, *sslhost = NULL; int ishttpsurl = 0; #endif /* !NOSSL */ @@ -366,7 +366,7 @@ url_get(const char *origline, const char *proxyenv, const char *outfile, int las scheme = FTP_URL; #endif /* !SMALL */ } else if (strncasecmp(newline, HTTPS_URL, sizeof(HTTPS_URL) - 1) == 0) { -#ifndef NOSSL +#if !defined(NOSSL) || !NOSSL host = newline + sizeof(HTTPS_URL) - 1; ishttpsurl = 1; #else @@ -444,7 +444,7 @@ noslash: #endif /* !SMALL */ if (proxyenv != NULL) { /* use proxy */ -#ifndef NOSSL +#if !defined(NOSSL) || !NOSSL if (ishttpsurl) { sslpath = strdup(path); sslhost = strdup(host); @@ -514,7 +514,7 @@ noslash: portnum = strrchr(hosttail, ':'); /* find portnum */ if (portnum != NULL) *portnum++ = '\0'; -#ifndef NOSSL +#if !defined(NOSSL) || !NOSSL port = portnum ? portnum : (ishttpsurl ? httpsport : httpport); #else /* !NOSSL */ port = portnum ? portnum : httpport; @@ -541,7 +541,7 @@ noslash: if (error == EAI_SERVICE && port == httpport) { snprintf(pbuf, sizeof(pbuf), "%d", HTTP_PORT); error = getaddrinfo(host, pbuf, &hints, &res0); -#ifndef NOSSL +#if !defined(NOSSL) || !NOSSL } else if (error == EAI_SERVICE && port == httpsport) { snprintf(pbuf, sizeof(pbuf), "%d", HTTPS_PORT); error = getaddrinfo(host, pbuf, &hints, &res0); @@ -619,7 +619,7 @@ noslash: else port = NULL; -#ifndef NOSSL +#if !defined(NOSSL) || !NOSSL if (proxyenv && sslhost) proxy_connect(fd, sslhost, proxy_credentials); #endif /* !NOSSL */ @@ -635,7 +635,7 @@ noslash: goto cleanup_url_get; } -#ifndef NOSSL +#if !defined(NOSSL) || !NOSSL if (ishttpsurl) { ssize_t ret; if (proxyenv && sslpath) { @@ -694,7 +694,7 @@ noslash: /* * Construct and send the request. Proxy requests don't want leading /. */ -#ifndef NOSSL +#if !defined(NOSSL) || !NOSSL cookie_get(host, path, ishttpsurl, &buf); #endif /* !NOSSL */ @@ -763,7 +763,7 @@ noslash: * 80. Some broken HTTP servers get confused if you explicitly * send them the port number. */ -#ifndef NOSSL +#if !defined(NOSSL) || !NOSSL if (port && strcmp(port, (ishttpsurl ? "443" : "80")) != 0) ftp_printf(fin, ":%s", port); if (restart_point) @@ -788,7 +788,7 @@ noslash: } free(epath); -#ifndef NOSSL +#if !defined(NOSSL) || !NOSSL free(buf); #endif /* !NOSSL */ buf = NULL; @@ -1127,7 +1127,7 @@ cleanup_url_get: #ifndef SMALL free(full_host); #endif /* !SMALL */ -#ifndef NOSSL +#if !defined(NOSSL) || !NOSSL free(sslhost); #endif /* !NOSSL */ ftp_close(&fin, &tls, &fd); @@ -1645,7 +1645,7 @@ isurl(const char *p) if (strncasecmp(p, FTP_URL, sizeof(FTP_URL) - 1) == 0 || strncasecmp(p, HTTP_URL, sizeof(HTTP_URL) - 1) == 0 || -#ifndef NOSSL +#if !defined(NOSSL) || !NOSSL strncasecmp(p, HTTPS_URL, sizeof(HTTPS_URL) - 1) == 0 || #endif /* !NOSSL */ strncasecmp(p, FILE_URL, sizeof(FILE_URL) - 1) == 0 || @@ -1678,7 +1678,7 @@ ftp_printf(FILE *fp, const char *fmt, ...) static void ftp_close(FILE **fin, tls_t *tls, int *fd) { -#ifndef NOSSL +#if !defined(NOSSL) || !NOSSL int ret; if (*tls != NULL) { @@ -1706,7 +1706,7 @@ static const char * sockerror(tls_t tls) { int save_errno = errno; -#ifndef NOSSL +#if !defined(NOSSL) || !NOSSL if (tls != NULL) { const char *tlserr = tls_error(tls); if (tlserr != NULL) @@ -1716,7 +1716,7 @@ sockerror(tls_t tls) return strerror(save_errno); } -#ifndef NOSSL +#if !defined(NOSSL) || !NOSSL static int proxy_connect(int socket, char *host, char *cookie) { diff --git a/ftp_var.h b/ftp_var.h index 878ae4d..1e217ec 100644 --- a/ftp_var.h +++ b/ftp_var.h @@ -75,7 +75,7 @@ #include #endif /* !SMALL */ -#ifndef NOSSL +#if !defined(NOSSL) || !NOSSL #ifdef __OpenBSD__ #include #else @@ -181,7 +181,7 @@ extern int unix_proxy; /* proxy is unix, can use binary for ascii */ extern char *ftpport; /* port number to use for ftp connections */ extern char *httpport; /* port number to use for http connections */ -#ifndef NOSSL +#if !defined(NOSSL) || !NOSSL extern char *httpsport; /* port number to use for https connections */ #endif /* !SMALL */ extern char *httpuseragent; /* user agent for http(s) connections */ @@ -234,7 +234,7 @@ extern FILE *ttyout; /* stdout or stderr, depending on interactive */ extern struct cmd cmdtab[]; -#ifndef NOSSL +#if !defined(NOSSL) || !NOSSL #include "tls_compat.h" extern tls_config_t tls_config; extern int tls_session_fd; diff --git a/main.c b/main.c index 0124714..881e036 100644 --- a/main.c +++ b/main.c @@ -75,7 +75,7 @@ #include #include -#ifndef NOSSL +#if !defined(NOSSL) || !NOSSL #include "tls_compat.h" #endif @@ -160,7 +160,7 @@ int unix_proxy; char *ftpport; char *httpport; -#ifndef NOSSL +#if !defined(NOSSL) || !NOSSL char *httpsport; #endif /* !SMALL */ char *httpuseragent; @@ -196,7 +196,7 @@ int connect_timeout; int server_timestamps = 1; #endif -#ifndef NOSSL +#if !defined(NOSSL) || !NOSSL char * const ssl_verify_opts[] = { #define SSL_CAFILE 0 "cafile", @@ -325,7 +325,7 @@ main(volatile int argc, char *argv[]) ftpport = "ftp"; httpport = "http"; -#ifndef NOSSL +#if !defined(NOSSL) || !NOSSL httpsport = "https"; #endif /* !NOSSL */ gateport = getenv("FTPSERVERPORT"); @@ -340,7 +340,7 @@ main(volatile int argc, char *argv[]) verbose = 0; progress = 0; gatemode = 0; -#ifndef NOSSL +#if !defined(NOSSL) || !NOSSL cookiefile = NULL; #endif /* NOSSL */ #ifndef SMALL @@ -402,7 +402,7 @@ main(volatile int argc, char *argv[]) if (isatty(fileno(ttyout)) && !dumb_terminal && foregroundproc()) progress = 1; /* progress bar on if tty is usable */ -#ifndef NOSSL +#if !defined(NOSSL) || !NOSSL cookiefile = getenv("http_cookies"); if (tls_config == NULL) { tls_config = tls_config_new(); @@ -526,7 +526,7 @@ main(volatile int argc, char *argv[]) break; case 'S': -#ifndef NOSSL +#if !defined(NOSSL) || !NOSSL process_ssl_options(optarg); #endif /* !NOSSL */ break; @@ -581,7 +581,7 @@ main(volatile int argc, char *argv[]) argc -= optind; argv += optind; -#ifndef NOSSL +#if !defined(NOSSL) || !NOSSL cookie_load(); #endif /* !NOSSL */ if (httpuseragent == NULL) @@ -1079,7 +1079,7 @@ usage(void) #else /* !SMALL */ "ftp [-N name] [-o output] " "ftp://[user:password@]host[:port]/file[/] ...\n" -#ifndef NOSSL +#if !defined(NOSSL) || !NOSSL " ftp [-N name] [-o output] [-S ssl_options] [-w seconds] " "http[s]://[user:password@]host[:port]/file ...\n" #else diff --git a/tls_compat.c b/tls_compat.c index cde80a9..94b2528 100644 --- a/tls_compat.c +++ b/tls_compat.c @@ -1,6 +1,6 @@ #include "tls_compat.h" -#ifndef NOSSL +#if !defined(NOSSL) || !NOSSL #include #include -- cgit 1.4.1