| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: fetch.c,v 1.235.2.1 2023/05/16 16:16:00 martin Exp $ */ | | 1 | /* $NetBSD: fetch.c,v 1.235.2.2 2024/01/15 16:12:08 martin Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1997-2015 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1997-2015 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Luke Mewburn. | | 8 | * by Luke Mewburn. |
9 | * | | 9 | * |
10 | * This code is derived from software contributed to The NetBSD Foundation | | 10 | * This code is derived from software contributed to The NetBSD Foundation |
11 | * by Scott Aaron Bamford. | | 11 | * by Scott Aaron Bamford. |
12 | * | | 12 | * |
13 | * This code is derived from software contributed to The NetBSD Foundation | | 13 | * This code is derived from software contributed to The NetBSD Foundation |
14 | * by Thomas Klausner. | | 14 | * by Thomas Klausner. |
| @@ -27,27 +27,27 @@ | | | @@ -27,27 +27,27 @@ |
27 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 27 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
28 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 28 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
29 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 29 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
35 | * POSSIBILITY OF SUCH DAMAGE. | | 35 | * POSSIBILITY OF SUCH DAMAGE. |
36 | */ | | 36 | */ |
37 | | | 37 | |
38 | #include <sys/cdefs.h> | | 38 | #include <sys/cdefs.h> |
39 | #ifndef lint | | 39 | #ifndef lint |
40 | __RCSID("$NetBSD: fetch.c,v 1.235.2.1 2023/05/16 16:16:00 martin Exp $"); | | 40 | __RCSID("$NetBSD: fetch.c,v 1.235.2.2 2024/01/15 16:12:08 martin Exp $"); |
41 | #endif /* not lint */ | | 41 | #endif /* not lint */ |
42 | | | 42 | |
43 | /* | | 43 | /* |
44 | * FTP User Program -- Command line file retrieval | | 44 | * FTP User Program -- Command line file retrieval |
45 | */ | | 45 | */ |
46 | | | 46 | |
47 | #include <sys/types.h> | | 47 | #include <sys/types.h> |
48 | #include <sys/param.h> | | 48 | #include <sys/param.h> |
49 | #include <sys/socket.h> | | 49 | #include <sys/socket.h> |
50 | #include <sys/stat.h> | | 50 | #include <sys/stat.h> |
51 | #include <sys/time.h> | | 51 | #include <sys/time.h> |
52 | | | 52 | |
53 | #include <netinet/in.h> | | 53 | #include <netinet/in.h> |
| @@ -791,27 +791,32 @@ handle_proxy(const char *url, const char | | | @@ -791,27 +791,32 @@ handle_proxy(const char *url, const char |
791 | initurlinfo(&pui); | | 791 | initurlinfo(&pui); |
792 | if (parse_url(penv, "proxy URL", &pui, pauth, NULL) == -1) | | 792 | if (parse_url(penv, "proxy URL", &pui, pauth, NULL) == -1) |
793 | return -1; | | 793 | return -1; |
794 | | | 794 | |
795 | if ((!IS_HTTP_TYPE(pui.utype) && pui.utype != FTP_URL_T) || | | 795 | if ((!IS_HTTP_TYPE(pui.utype) && pui.utype != FTP_URL_T) || |
796 | EMPTYSTRING(pui.host) || | | 796 | EMPTYSTRING(pui.host) || |
797 | (! EMPTYSTRING(pui.path) && strcmp(pui.path, "/") != 0)) { | | 797 | (! EMPTYSTRING(pui.path) && strcmp(pui.path, "/") != 0)) { |
798 | warnx("Malformed proxy URL `%s'", penv); | | 798 | warnx("Malformed proxy URL `%s'", penv); |
799 | freeurlinfo(&pui); | | 799 | freeurlinfo(&pui); |
800 | return -1; | | 800 | return -1; |
801 | } | | 801 | } |
802 | | | 802 | |
803 | FREEPTR(pui.path); | | 803 | FREEPTR(pui.path); |
804 | pui.path = ftp_strdup(url); | | 804 | #ifdef WITH_SSL |
| | | 805 | if (ui->utype == HTTPS_URL_T) |
| | | 806 | pui.path = ftp_strdup(ui->path); |
| | | 807 | else |
| | | 808 | #endif |
| | | 809 | pui.path = ftp_strdup(url); |
805 | | | 810 | |
806 | freeurlinfo(ui); | | 811 | freeurlinfo(ui); |
807 | *ui = pui; | | 812 | *ui = pui; |
808 | | | 813 | |
809 | return 0; | | 814 | return 0; |
810 | } | | 815 | } |
811 | | | 816 | |
812 | static void | | 817 | static void |
813 | print_host(FETCH *fin, const struct urlinfo *ui) | | 818 | print_host(FETCH *fin, const struct urlinfo *ui) |
814 | { | | 819 | { |
815 | char *h, *p; | | 820 | char *h, *p; |
816 | | | 821 | |
817 | if (strchr(ui->host, ':') == NULL) { | | 822 | if (strchr(ui->host, ':') == NULL) { |
| @@ -1637,29 +1642,30 @@ fetch_url(const char *url, const char *p | | | @@ -1637,29 +1642,30 @@ fetch_url(const char *url, const char *p |
1637 | if (strcmp(savefile, "-") == 0) { | | 1642 | if (strcmp(savefile, "-") == 0) { |
1638 | fout = stdout; | | 1643 | fout = stdout; |
1639 | } else if (*savefile == '|') { | | 1644 | } else if (*savefile == '|') { |
1640 | oldpipe = xsignal(SIGPIPE, SIG_IGN); | | 1645 | oldpipe = xsignal(SIGPIPE, SIG_IGN); |
1641 | fout = popen(savefile + 1, "w"); | | 1646 | fout = popen(savefile + 1, "w"); |
1642 | if (fout == NULL) { | | 1647 | if (fout == NULL) { |
1643 | warn("Can't execute `%s'", savefile + 1); | | 1648 | warn("Can't execute `%s'", savefile + 1); |
1644 | goto cleanup_fetch_url; | | 1649 | goto cleanup_fetch_url; |
1645 | } | | 1650 | } |
1646 | closefunc = pclose; | | 1651 | closefunc = pclose; |
1647 | } | | 1652 | } |
1648 | } | | 1653 | } |
1649 | if (fout == NULL) { | | 1654 | if (fout == NULL) { |
1650 | if ((pi.rangeend != -1 && pi.rangeend <= restart_point) || | | 1655 | if (restart_point && ( |
| | | 1656 | (pi.rangeend != -1 && pi.rangeend <= restart_point) || |
1651 | (pi.rangestart == -1 && | | 1657 | (pi.rangestart == -1 && |
1652 | filesize != -1 && filesize <= restart_point)) { | | 1658 | filesize != -1 && filesize <= restart_point))) { |
1653 | /* already done */ | | 1659 | /* already done */ |
1654 | if (verbose) | | 1660 | if (verbose) |
1655 | fprintf(ttyout, "already done\n"); | | 1661 | fprintf(ttyout, "already done\n"); |
1656 | rval = 0; | | 1662 | rval = 0; |
1657 | goto cleanup_fetch_url; | | 1663 | goto cleanup_fetch_url; |
1658 | } | | 1664 | } |
1659 | if (restart_point && pi.rangestart != -1) { | | 1665 | if (restart_point && pi.rangestart != -1) { |
1660 | if (pi.entitylen != -1) | | 1666 | if (pi.entitylen != -1) |
1661 | filesize = pi.entitylen; | | 1667 | filesize = pi.entitylen; |
1662 | if (pi.rangestart != restart_point) { | | 1668 | if (pi.rangestart != restart_point) { |
1663 | warnx( | | 1669 | warnx( |
1664 | "Size of `%s' differs from save file `%s'", | | 1670 | "Size of `%s' differs from save file `%s'", |
1665 | url, savefile); | | 1671 | url, savefile); |