Module Name:    src
Committed By:   martin
Date:           Mon Jan 15 16:12:08 UTC 2024

Modified Files:
        src/usr.bin/ftp [netbsd-10]: fetch.c

Log Message:
Pull up following revision(s) (requested by mlelstv in ticket #555):

        usr.bin/ftp/fetch.c: revision 1.237
        usr.bin/ftp/fetch.c: revision 1.238

Fix HTTPS through Proxy.

While a regular HTTP Proxy, requires the absolute URL with protocol
and host part, yyou must only send the relative URL through a
CONNECT tunnel (you are talking to the target server).

Don't finish downloading an empty file with 'already done' before it is
created locally.


To generate a diff of this commit:
cvs rdiff -u -r1.235.2.1 -r1.235.2.2 src/usr.bin/ftp/fetch.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/ftp/fetch.c
diff -u src/usr.bin/ftp/fetch.c:1.235.2.1 src/usr.bin/ftp/fetch.c:1.235.2.2
--- src/usr.bin/ftp/fetch.c:1.235.2.1	Tue May 16 16:16:00 2023
+++ src/usr.bin/ftp/fetch.c	Mon Jan 15 16:12:08 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: fetch.c,v 1.235.2.1 2023/05/16 16:16:00 martin Exp $	*/
+/*	$NetBSD: fetch.c,v 1.235.2.2 2024/01/15 16:12:08 martin Exp $	*/
 
 /*-
  * Copyright (c) 1997-2015 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: fetch.c,v 1.235.2.1 2023/05/16 16:16:00 martin Exp $");
+__RCSID("$NetBSD: fetch.c,v 1.235.2.2 2024/01/15 16:12:08 martin Exp $");
 #endif /* not lint */
 
 /*
@@ -801,7 +801,12 @@ handle_proxy(const char *url, const char
 	}
 
 	FREEPTR(pui.path);
-	pui.path = ftp_strdup(url);
+#ifdef WITH_SSL
+	if (ui->utype == HTTPS_URL_T)
+		pui.path = ftp_strdup(ui->path);
+	else
+#endif
+		pui.path = ftp_strdup(url);
 
 	freeurlinfo(ui);
 	*ui = pui;
@@ -1647,9 +1652,10 @@ fetch_url(const char *url, const char *p
 		}
 	}
 	if (fout == NULL) {
-		if ((pi.rangeend != -1 && pi.rangeend <= restart_point) ||
+		if (restart_point && (
+		    (pi.rangeend != -1 && pi.rangeend <= restart_point) ||
 		    (pi.rangestart == -1 &&
-		    filesize != -1 && filesize <= restart_point)) {
+		    filesize != -1 && filesize <= restart_point))) {
 			/* already done */
 			if (verbose)
 				fprintf(ttyout, "already done\n");

Reply via email to