OpenBSD CVS

CVS log for src/usr.bin/ftp/fetch.c


[BACK] Up to [local] / src / usr.bin / ftp

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.218 / (download) - annotate - [select for diffs], Tue Apr 23 08:50:38 2024 UTC (3 weeks, 5 days ago) by sthen
Branch: MAIN
CVS Tags: HEAD
Changes since 1.217: +6 -4 lines
Diff to previous 1.217 (colored)

ftp: send Host: headers with CONNECT requests when tunneling TLS over an
HTTP proxy (i.e. for fetching resources over https). This is required by
some proxy servers.

Ftom KUWAZAWA Takuya, ok tb@

Revision 1.217 / (download) - annotate - [select for diffs], Wed Apr 17 09:51:18 2024 UTC (4 weeks, 3 days ago) by tb
Branch: MAIN
Changes since 1.216: +5 -4 lines
Diff to previous 1.216 (colored)

ftp: send 'Accept */*' header

A recent update to filezilla showed a server that would refuse to let us
download the distfile without us sending this header. Browsers, curl and
wget do so, so it should be safe for us to follow suit.

ok deraadt florian phessler sthen

Revision 1.216 / (download) - annotate - [select for diffs], Wed Jun 28 17:35:06 2023 UTC (10 months, 3 weeks ago) by op
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, OPENBSD_7_4_BASE, OPENBSD_7_4
Changes since 1.215: +1 -6 lines
Diff to previous 1.215 (colored)

drop needless strcspn in the header parsing

since fetch.c revision 1.211, ftp removes trailingwhitespaces early so
there's no need to re-do that when parsing a header.

while here, remove an unused variable too.

ok tb, millert

Revision 1.215 / (download) - annotate - [select for diffs], Wed Jun 28 11:07:28 2023 UTC (10 months, 3 weeks ago) by op
Branch: MAIN
Changes since 1.214: +2 -1 lines
Diff to previous 1.214 (colored)

fix parsing of the Last-Modified header

Was overlooked in r1.209.

diff from 'a dog' (OpenBSD [at] anthropomorphic [dot] dog)
ok tb, sthen

Revision 1.214 / (download) - annotate - [select for diffs], Wed Mar 8 04:43:11 2023 UTC (14 months, 1 week ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_7_3_BASE, OPENBSD_7_3
Changes since 1.213: +1 -2 lines
Diff to previous 1.213 (colored)

Delete obsolete /* ARGSUSED */ lint comments.

ok miod@ millert@

Revision 1.213 / (download) - annotate - [select for diffs], Mon Dec 26 19:16:01 2022 UTC (16 months, 3 weeks ago) by jmc
Branch: MAIN
Changes since 1.212: +2 -2 lines
Diff to previous 1.212 (colored)

spelling fixes; from paul tagliamonte
amendments to his diff are noted on tech

Revision 1.212 / (download) - annotate - [select for diffs], Wed Nov 9 17:41:05 2022 UTC (18 months, 1 week ago) by claudio
Branch: MAIN
Changes since 1.211: +8 -3 lines
Diff to previous 1.211 (colored)

Before printing the redirect URI pass it through stravis since it is
untrusted input.
OK tb@ kn@ millert@

Revision 1.211 / (download) - annotate - [select for diffs], Wed Nov 9 16:29:58 2022 UTC (18 months, 1 week ago) by claudio
Branch: MAIN
Changes since 1.210: +4 -3 lines
Diff to previous 1.210 (colored)

Strip spaces at end of header lines and in chunked encoding headers.
HTTP standard allows for spaces in too many places
OK millert@ tb@

Revision 1.210 / (download) - annotate - [select for diffs], Thu Sep 15 12:47:10 2022 UTC (20 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_7_2_BASE, OPENBSD_7_2
Changes since 1.209: +3 -23 lines
Diff to previous 1.209 (colored)

Use non-blocking connect() with ppoll() and timeout instead of alarm().
For hosts with multiple IP addrs this makes it possible to fall
over from an unresponsive IP to another.  This also replaces the
other connect(2) + connect_wait() calls with timed_connect() so the
-w option now works for more that just http.  OK sthen@ deraadt@

Revision 1.209 / (download) - annotate - [select for diffs], Thu Sep 8 11:12:44 2022 UTC (20 months, 1 week ago) by claudio
Branch: MAIN
Changes since 1.208: +12 -11 lines
Diff to previous 1.208 (colored)

Adjust HTTP header parsing to follow RFC more closely.

RFC9112 allows any amount of space/tabs between the ':' and the value.
Until now this code required exactly one space which works most of the
time but is not RFC compliant.
OK djm@

Revision 1.208 / (download) - annotate - [select for diffs], Wed Nov 10 07:32:55 2021 UTC (2 years, 6 months ago) by kn
Branch: MAIN
CVS Tags: OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.207: +3 -30 lines
Diff to previous 1.207 (colored)

Revert previous

I overlooked the autoinstall case where "Requesting ..." is used,
but those messages that got fixed where omitted in ftp's SMALL version.

Noticed the hard way by anton

Revision 1.207 / (download) - annotate - [select for diffs], Tue Nov 9 12:14:35 2021 UTC (2 years, 6 months ago) by kn
Branch: MAIN
Changes since 1.206: +31 -4 lines
Diff to previous 1.206 (colored)

Print actually requested URLs

Encoding URL paths changes the requested URL and therefore may yield
different responses (opposed to an unencoded URL), solely depending on how
the server implements de/encoding.

Always print the encoded URL which actually gets requested in output like
"Requesting ..." and erors likes "Error retrieving ....: 404 Not Found"
and don't use the original URL provided on the command line.

This matches exactly what is seen on the wire, e.g. with tshark(1) and
helps debugging URL de/encoding related (server) issues.

Feedback OK sthen

Revision 1.206 / (download) - annotate - [select for diffs], Sat Nov 6 14:27:45 2021 UTC (2 years, 6 months ago) by kn
Branch: MAIN
Changes since 1.205: +15 -14 lines
Diff to previous 1.205 (colored)

Stop URL encoding the tilde character

RFC 1738 Uniform Resource Locators (URL) lists tilde as unsafe character.
RFC 2396 Uniform Resource Identifiers (URI): Generic Syntax updates it to

	The tilde "~" character was added to those in the "unreserved" set,
	since it is extensively used on the Internet in spite of the
	difficulty to transcribe it with some keyboards.

In theory, this shouldn't make a difference, but some servers do not decode
"%7e" and thus erroneously serve a 404.

RFC 2396 2.4.2. When to Escape and Unescape says:

	In some cases, data that could be represented by an unreserved
	character may appear escaped; for example, some of the unreserved
	"mark" characters are automatically escaped by some systems.  If the
	given URI scheme defines a canonicalization algorithm, then
	unreserved characters may be unescaped according to that algorithm.
	For example, "%7e" is sometimes used instead of "~" in an http URL
	path, but the two are equivalent for an http URL.


Update ftp(1) to RFC 2396 by no longer treating "~" as unsafe character.
This is effectively a one-character diff;  update comments accordingly as
well as the order of characters to ease code-to-standard comparison.

This matches curl(1) and wget(1) behaviour wrt. encoding of "~".

OK sthen

Revision 1.205 / (download) - annotate - [select for diffs], Tue Aug 31 09:51:25 2021 UTC (2 years, 8 months ago) by claudio
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0
Changes since 1.204: +7 -7 lines
Diff to previous 1.204 (colored)

Spacing. OK tb@

Revision 1.204 / (download) - annotate - [select for diffs], Mon Mar 29 03:34:52 2021 UTC (3 years, 1 month ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_6_9_BASE, OPENBSD_6_9
Changes since 1.203: +2 -2 lines
Diff to previous 1.203 (colored)

in unsafe_char(), handle %NN with array-index inspection rather than weird
ptr++
ok claudio

Revision 1.203 / (download) - annotate - [select for diffs], Sat Mar 13 11:36:31 2021 UTC (3 years, 2 months ago) by sthen
Branch: MAIN
Changes since 1.202: +3 -2 lines
Diff to previous 1.202 (colored)

only try to set timestamps on files; avoids error with ftp -o /dev/null
ok jca robert

Revision 1.202 / (download) - annotate - [select for diffs], Thu Feb 25 20:51:55 2021 UTC (3 years, 2 months ago) by naddy
Branch: MAIN
Changes since 1.201: +2 -1 lines
Diff to previous 1.201 (colored)

ftp: prevent double free() in error path

Reported by bentley@; ok bentley@ jca@

Revision 1.201 / (download) - annotate - [select for diffs], Tue Feb 16 16:27:34 2021 UTC (3 years, 3 months ago) by naddy
Branch: MAIN
Changes since 1.200: +13 -19 lines
Diff to previous 1.200 (colored)

make use of getline(3) in ftp(1)

Replace fparseln(3) with getline(3).  This removes the only use of
libutil.a(fparseln.o) from the ramdisk.
Replace a complicated fgetln(3) idiom with the much simpler getline(3).

ok jca@

Revision 1.200 / (download) - annotate - [select for diffs], Tue Feb 2 12:58:42 2021 UTC (3 years, 3 months ago) by robert
Branch: MAIN
Changes since 1.199: +46 -8 lines
Diff to previous 1.199 (colored)

introduce support for sending the If-Modified-Since header while
fetching over http(s) and use the timestamps from the remote server's
Last-Modified header if available when saving local files
this makes it possible to mirror files better with ftp(1)

the new timestamp behaviour can be disabled with the new '-u' flag

ok sthen@, input from sthen@ and gnezdo@

Revision 1.199 / (download) - annotate - [select for diffs], Fri Jan 1 17:39:54 2021 UTC (3 years, 4 months ago) by chrisz
Branch: MAIN
Changes since 1.198: +2 -1 lines
Diff to previous 1.198 (colored)

Handle Permanent Redirect (RFC 7538)

ok jca@, kn@

Revision 1.198 / (download) - annotate - [select for diffs], Sun Oct 18 20:35:18 2020 UTC (3 years, 7 months ago) by naddy
Branch: MAIN
Changes since 1.197: +17 -6 lines
Diff to previous 1.197 (colored)

Accommodate POSIX basename(3) that takes a non-const parameter and
may modify the string buffer.

improved and ok jca@

Revision 1.197 / (download) - annotate - [select for diffs], Sat Jul 4 11:23:35 2020 UTC (3 years, 10 months ago) by kn
Branch: MAIN
CVS Tags: OPENBSD_6_8_BASE, OPENBSD_6_8
Changes since 1.196: +4 -19 lines
Diff to previous 1.196 (colored)

Avoid malloc(3) calls in signal handler

Fetch aborts through SIGINT (^C) print a message with fputs(3), but this
calls malloc() on its own, which is not supported from interrupt handler
context.

Fix it by using write(2) which avoids further memory allocations.
While here, merge abortfile() into the identical aborthttp() with a more
generic "fetch aborted." message for simplicity.

Spotted with vm.malloc_conf=SU and ^C on a port's "make fetch" causing

ftp(49660) in malloc(): recursive call
Abort trap (core dumped)

OK jca (who came up with using write(2) independently)

Revision 1.196 / (download) - annotate - [select for diffs], Sat Jul 4 10:18:49 2020 UTC (3 years, 10 months ago) by jca
Branch: MAIN
Changes since 1.195: +6 -3 lines
Diff to previous 1.195 (colored)

Fix a double free in error paths

Consistently disarm the SIGINT handler on error, else a SIGINT can lead
to taking twice the cleanup path.  Initial report by naddy@, ok tb@

Revision 1.195 / (download) - annotate - [select for diffs], Sat Jun 20 09:59:48 2020 UTC (3 years, 10 months ago) by jca
Branch: MAIN
Changes since 1.194: +2 -2 lines
Diff to previous 1.194 (colored)

Avoid one uninitialized warning in file_get()

Revision 1.194 / (download) - annotate - [select for diffs], Sat Feb 22 01:00:07 2020 UTC (4 years, 2 months ago) by jca
Branch: MAIN
CVS Tags: OPENBSD_6_7_BASE, OPENBSD_6_7
Changes since 1.193: +9 -14 lines
Diff to previous 1.193 (colored)

Avoid duplication in the code that sends headers

ok yasuoka@

Revision 1.193 / (download) - annotate - [select for diffs], Sat Feb 22 00:58:28 2020 UTC (4 years, 2 months ago) by jca
Branch: MAIN
Changes since 1.192: +3 -10 lines
Diff to previous 1.192 (colored)

Respect userinfo even when built with NOSSL (floppy ramdisks)

Not handling it is incorrect and can lead to credentials leaks in DNS
requests.  The resulting growth is reasonable (about 300 bytes on
amd64).

ok yasuoka@

Revision 1.192 / (download) - annotate - [select for diffs], Thu Feb 20 00:45:09 2020 UTC (4 years, 2 months ago) by yasuoka
Branch: MAIN
Changes since 1.191: +3 -19 lines
Diff to previous 1.191 (colored)

Backout revision 1.190 partially.  That part was an unintended change which
is work in progress.

Revision 1.191 / (download) - annotate - [select for diffs], Wed Feb 19 12:39:38 2020 UTC (4 years, 2 months ago) by jca
Branch: MAIN
Changes since 1.190: +21 -17 lines
Diff to previous 1.190 (colored)

Fix http (not https) auth combined with proxy auth.

First look for userinfo, and overwrite it to make sure it doesn't
reappears again later.

Then reset the path to fix the fragile mechanism that produces the full
request URI for the proxied connection case.

ok yazuoka@

Revision 1.190 / (download) - annotate - [select for diffs], Wed Feb 19 07:29:53 2020 UTC (4 years, 2 months ago) by yasuoka
Branch: MAIN
Changes since 1.189: +34 -18 lines
Diff to previous 1.189 (colored)

Don't put the userinfo in request URI.  This also makes accessing a
https server with user/password through "http_proxy" environment
variable work properly.

ok jca

Revision 1.189 / (download) - annotate - [select for diffs], Thu Feb 13 15:54:10 2020 UTC (4 years, 3 months ago) by jca
Branch: MAIN
Changes since 1.188: +10 -10 lines
Diff to previous 1.188 (colored)

Two longjmp(3) vs volatile fixes and improvements

- allocate read buffer before setjmp(3) so that its value is properly
defined when longjmp(3) returns
- only mark as volatile variables modified after setjmp(3) and used
again after a possible return from longjmp(3)

Revision 1.188 / (download) - annotate - [select for diffs], Thu Feb 13 15:47:33 2020 UTC (4 years, 3 months ago) by jca
Branch: MAIN
Changes since 1.187: +8 -10 lines
Diff to previous 1.187 (colored)

Fixes and tweaks for read/write loop in url_get()

Changes already present in file_get()
- no need to special case write(2) returning 0
- clearer loop condition
- fix read error detection and properly save errno

Revision 1.187 / (download) - annotate - [select for diffs], Tue Jan 21 05:02:53 2020 UTC (4 years, 3 months ago) by beck
Branch: MAIN
Changes since 1.186: +9 -5 lines
Diff to previous 1.186 (colored)

Fix tls_handshake() usage which was added without checking return values
correctly. This would break ftp when the handshake doesn't complete in one
shot. (noticed when making tls 1.3 connections to cloudflare.cdn)
ok jsing@

Revision 1.186 / (download) - annotate - [select for diffs], Wed Jan 15 14:49:38 2020 UTC (4 years, 4 months ago) by jca
Branch: MAIN
Changes since 1.185: +148 -142 lines
Diff to previous 1.185 (colored)

Move local file handling out of url_get()

The code is mostly duplicated already, handling local files here just
makes for more complex code.  Split it out to its own function.  This
mechanically prevents redirections to local files.

Positive feedback from Hiltjo Posthuma

Revision 1.172.2.1 / (download) - annotate - [select for diffs], Thu Dec 19 16:50:22 2019 UTC (4 years, 5 months ago) by deraadt
Branch: OPENBSD_6_6
Changes since 1.172: +4 -1 lines
Diff to previous 1.172 (colored) next main 1.173 (colored)

Prevent redirections to file: URLs

Report and fix from Hiltjo Posthuma, input from and ok deraadt@
this is errata 6.6/015_ftp.patch.sig

Revision 1.167.6.1 / (download) - annotate - [select for diffs], Thu Dec 19 16:49:47 2019 UTC (4 years, 5 months ago) by deraadt
Branch: OPENBSD_6_5
Changes since 1.167: +4 -1 lines
Diff to previous 1.167 (colored) next main 1.168 (colored)

Prevent redirections to file: URLs

Report and fix from Hiltjo Posthuma, input from and ok deraadt@
this is errata 6.5/026_ftp.patch.sig

Revision 1.185 / (download) - annotate - [select for diffs], Thu Dec 19 00:07:20 2019 UTC (4 years, 5 months ago) by jca
Branch: MAIN
Changes since 1.184: +4 -1 lines
Diff to previous 1.184 (colored)

Prevent redirections to file: URLs

Report and fix from Hiltjo Posthuma, input from and ok deraadt@

Revision 1.184 / (download) - annotate - [select for diffs], Mon Dec 9 19:05:06 2019 UTC (4 years, 5 months ago) by jca
Branch: MAIN
Changes since 1.183: +38 -12 lines
Diff to previous 1.183 (colored)

Reinstate ftp_printf to log sent HTTP headers

On SMALL builds ftp_printf is just a #define to avoid a size increase.
ok millert@

Revision 1.183 / (download) - annotate - [select for diffs], Mon Dec 9 00:45:34 2019 UTC (4 years, 5 months ago) by jca
Branch: MAIN
Changes since 1.182: +5 -6 lines
Diff to previous 1.182 (colored)

With NOSSL let url_get() print a nice error message for https urls

Input from deraadt@

Revision 1.182 / (download) - annotate - [select for diffs], Sun Dec 8 23:43:53 2019 UTC (4 years, 5 months ago) by jca
Branch: MAIN
Changes since 1.181: +4 -4 lines
Diff to previous 1.181 (colored)

For chunked transfers always restore the SIGINFO handler (not just on error)

Overlooked when shuffling the HTTP/1.1 code.

Revision 1.181 / (download) - annotate - [select for diffs], Thu Dec 5 10:26:25 2019 UTC (4 years, 5 months ago) by jca
Branch: MAIN
Changes since 1.180: +15 -7 lines
Diff to previous 1.180 (colored)

Fix #ifndef NOSSL vs SMALL inconsistencies

from Hiltjo Posthuma

Revision 1.180 / (download) - annotate - [select for diffs], Mon Dec 2 22:32:18 2019 UTC (4 years, 5 months ago) by jca
Branch: MAIN
Changes since 1.179: +1 -2 lines
Diff to previous 1.179 (colored)

Tweak inaccurate comment

Revision 1.179 / (download) - annotate - [select for diffs], Mon Nov 18 04:37:35 2019 UTC (4 years, 6 months ago) by deraadt
Branch: MAIN
Changes since 1.178: +6 -8 lines
Diff to previous 1.178 (colored)

various knf and whitespace; ok jca

Revision 1.178 / (download) - annotate - [select for diffs], Thu Nov 14 23:48:37 2019 UTC (4 years, 6 months ago) by jca
Branch: MAIN
Changes since 1.177: +125 -39 lines
Diff to previous 1.177 (colored)

HTTP/1.1 for ftp(1)

Some sites in ports start to reject HTTP/1.0 requests.  Let's move on
and implement HTTP/1.1.  Should fit in ramdisks.

ok sthen@ tb@

Revision 1.177 / (download) - annotate - [select for diffs], Mon Nov 4 15:36:36 2019 UTC (4 years, 6 months ago) by jca
Branch: MAIN
Changes since 1.176: +23 -23 lines
Diff to previous 1.176 (colored)

Apply more 'static' to help the compiler

Results in better code and a size decrease.

Revision 1.176 / (download) - annotate - [select for diffs], Sun Nov 3 19:26:15 2019 UTC (4 years, 6 months ago) by jca
Branch: MAIN
Changes since 1.175: +73 -143 lines
Diff to previous 1.175 (colored)

Also use stdio for TLS connections

Set up two wrappers around tls_read/write to be used along with the
not-very-portable funopen().  This kills a bunch of local code, always
a nice thing for an utility which ends up in bsd.rd.

"seems legit" deraadt@, ok kn@

Revision 1.175 / (download) - annotate - [select for diffs], Wed Oct 23 16:47:53 2019 UTC (4 years, 6 months ago) by deraadt
Branch: MAIN
Changes since 1.174: +9 -5 lines
Diff to previous 1.174 (colored)

change some error reports to include the failing URL (which we vis, in
case it came via a redirect)
some help from jca, discussed with aja

Revision 1.174 / (download) - annotate - [select for diffs], Sun Oct 13 15:09:26 2019 UTC (4 years, 7 months ago) by jca
Branch: MAIN
Changes since 1.173: +1 -0 lines
Diff to previous 1.173 (colored)

Also close the server connection before retrying on a 503.

Keeping it around uses both local and remote resources for no good reason.

ok job@

Revision 1.173 / (download) - annotate - [select for diffs], Sun Oct 13 15:07:13 2019 UTC (4 years, 7 months ago) by jca
Branch: MAIN
Changes since 1.172: +31 -26 lines
Diff to previous 1.172 (colored)

Factor out socket cleanup code

As a side effect this shuts down the TLS connection before closing the
underlying socket for redirectionss.

ok job@

Revision 1.172 / (download) - annotate - [select for diffs], Wed Oct 9 16:43:22 2019 UTC (4 years, 7 months ago) by jca
Branch: MAIN
CVS Tags: OPENBSD_6_6_BASE
Branch point for: OPENBSD_6_6
Changes since 1.171: +26 -9 lines
Diff to previous 1.171 (colored)

On a 503, only retry if "Retry-After: 0" is present.

We just bail out if the header is absent or if the server tells us to
wait.  Prodding from job@, ok sthen@ deraadt@

Revision 1.171 / (download) - annotate - [select for diffs], Sat Oct 5 20:54:20 2019 UTC (4 years, 7 months ago) by jca
Branch: MAIN
Changes since 1.170: +13 -2 lines
Diff to previous 1.170 (colored)

Retry request once when receiving a 503

Basic implementation: we just retry once, and make no attempt (yet) to
parse any Retry-After header.

The idea is to work around cdn.openbsd.org sometimes replying with a 503
for reasons unknown.  According to juanfra@ it sets "Retry-After: 0" so
this minimal implementation should be enough.

Different diff from espie@, test case from sthen@, input from
millert@, ok millert@ deraadt@

Revision 1.170 / (download) - annotate - [select for diffs], Fri Jun 28 13:35:01 2019 UTC (4 years, 10 months ago) by deraadt
Branch: MAIN
Changes since 1.169: +6 -6 lines
Diff to previous 1.169 (colored)

When system calls indicate an error they return -1, not some arbitrary
value < 0.  errno is only updated in this case.  Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.

Revision 1.169 / (download) - annotate - [select for diffs], Thu May 16 12:44:17 2019 UTC (5 years ago) by florian
Branch: MAIN
Changes since 1.168: +0 -0 lines
Diff to previous 1.168 (colored)

Revert suni'ls ftp rewrite for now.
We are juggling too many things at the moment and we can't deal with
the differences in behaviour right now.

Revision 1.168, Sun May 12 20:44:39 2019 UTC (5 years ago) by kmos
Branch: MAIN
Changes since 1.167: +1 -1 lines
FILE REMOVED

Move us from old ftp(1) to Sunil's new ftp(1). The necessary modifications
have been made to make it behave. Any new misbehaviors can be fixed in tree.

OK florian@ deraadt@ "Have you committed ftp yet?"

Revision 1.167 / (download) - annotate - [select for diffs], Sat Feb 10 06:25:16 2018 UTC (6 years, 3 months ago) by jsing
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_4_BASE, OPENBSD_6_4, OPENBSD_6_3_BASE, OPENBSD_6_3
Branch point for: OPENBSD_6_5
Changes since 1.166: +4 -1 lines
Diff to previous 1.166 (colored)

Add TLS session support to ftp(1).

If a session file is specified via the `-S session=...', ftp(1) will
attempt to resume TLS sessions based on the session data contained within
this file. Upon completion of a successful TLS handshake the session file
will be updated with new session data, if available.

Discussed with deraadt@ and beck@.

Requested by and input from espie@.

Revision 1.166 / (download) - annotate - [select for diffs], Wed Feb 7 23:04:50 2018 UTC (6 years, 3 months ago) by procter
Branch: MAIN
Changes since 1.165: +32 -32 lines
Diff to previous 1.165 (colored)

rename var 's' -> 'fd' to ease finding it in a long function
ok tb@ deraadt@

Revision 1.165 / (download) - annotate - [select for diffs], Wed Feb 7 23:01:09 2018 UTC (6 years, 3 months ago) by procter
Branch: MAIN
Changes since 1.164: +15 -5 lines
Diff to previous 1.164 (colored)

eliminate close()/fclose() dance.
ok tb@ deraadt@

Revision 1.164 / (download) - annotate - [select for diffs], Mon Sep 25 11:04:54 2017 UTC (6 years, 7 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_6_2_BASE, OPENBSD_6_2
Changes since 1.163: +2 -2 lines
Diff to previous 1.163 (colored)

Initialize 'out' file descriptor to avoid possible
uninitialized use. Spotted by clang during 'make
release', triggered when both NOSSL and SMALL are
defined.

ok bluhm@ deraadt@

Revision 1.163 / (download) - annotate - [select for diffs], Tue Mar 7 08:00:23 2017 UTC (7 years, 2 months ago) by sunil
Branch: MAIN
CVS Tags: OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.162: +4 -2 lines
Diff to previous 1.162 (colored)

tls_close() can return TLS_WANT_POLLIN/TLS_WANT_POLLOUT, handle them
appropriately.

Ok jca@

Revision 1.162 / (download) - annotate - [select for diffs], Thu Mar 2 09:29:53 2017 UTC (7 years, 2 months ago) by sthen
Branch: MAIN
Changes since 1.161: +3 -1 lines
Diff to previous 1.161 (colored)

close ftp(1)'s output file to avoid leaking one FD per request.
ok deraadt

Revision 1.161 / (download) - annotate - [select for diffs], Tue Feb 28 06:31:12 2017 UTC (7 years, 2 months ago) by guenther
Branch: MAIN
Changes since 1.160: +10 -12 lines
Diff to previous 1.160 (colored)

Use a do{}while loop with ssize_t return value when calling tls_read()

problem noted by and ok jsg@

Revision 1.160 / (download) - annotate - [select for diffs], Sat Jan 21 08:33:07 2017 UTC (7 years, 3 months ago) by krw
Branch: MAIN
Changes since 1.159: +3 -3 lines
Diff to previous 1.159 (colored)

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.

Revision 1.159 / (download) - annotate - [select for diffs], Fri Jan 20 05:51:50 2017 UTC (7 years, 3 months ago) by krw
Branch: MAIN
Changes since 1.158: +6 -3 lines
Diff to previous 1.158 (colored)

Move a couple of variables that are unused in SMALL under #ifndef SMALL.

ok deraadt@

Revision 1.158 / (download) - annotate - [select for diffs], Sat Jan 14 18:03:11 2017 UTC (7 years, 4 months ago) by jca
Branch: MAIN
Changes since 1.157: +6 -8 lines
Diff to previous 1.157 (colored)

HTTPS proxy support for ftp-ssl.

The install media already allow for plaintext HTTP proxying.  The code
to support CONNECT is short enough.  Reported/fix tested by rpe@,  ok
deraadt@

Revision 1.157 / (download) - annotate - [select for diffs], Tue Jan 10 17:43:12 2017 UTC (7 years, 4 months ago) by deraadt
Branch: MAIN
Changes since 1.156: +29 -8 lines
Diff to previous 1.156 (colored)

Pledge more strictly.  This is only enabled on the ramdisk version of the
ftp(1) client, which operates only in URL mode.  Not willing to spend the
time tracking piles of global variables for sub-modes, and finding all
the pledge interactions.  Would rather have the install media ftp(1) as
safe as possible, immediately.
ok tb jca

Revision 1.156 / (download) - annotate - [select for diffs], Sat Jan 7 12:10:11 2017 UTC (7 years, 4 months ago) by tb
Branch: MAIN
Changes since 1.155: +2 -2 lines
Diff to previous 1.155 (colored)

-#endif /* !SMALL */
+#endif /* !NOSSL */

Revision 1.155 / (download) - annotate - [select for diffs], Tue Jan 3 17:00:04 2017 UTC (7 years, 4 months ago) by deraadt
Branch: MAIN
Changes since 1.154: +19 -1 lines
Diff to previous 1.154 (colored)

Add a "-w connect_timeout" option in support of URL-fetching.  This allows
slow / failing connects to be identified.  The install script needs this
functionaly.
ok jca rpe millert

Revision 1.154 / (download) - annotate - [select for diffs], Wed Dec 28 17:48:04 2016 UTC (7 years, 4 months ago) by deraadt
Branch: MAIN
Changes since 1.153: +45 -41 lines
Diff to previous 1.153 (colored)

Split -DSMALL into -DNOSSL, so that a SSL-enabled version of ftp can
be built, which is still pretty small (in distrib/special/ftp-ssl).
Lots of testing by rpe.

Revision 1.153 / (download) - annotate - [select for diffs], Sat Dec 24 13:52:42 2016 UTC (7 years, 4 months ago) by jsing
Branch: MAIN
Changes since 1.152: +7 -2 lines
Diff to previous 1.152 (colored)

Correctly handle tls_read()/tls_write().

In one tls_read() case, we failed to check for WANT_{POLLIN,POLLOUT}, so
fix that. In the same tls_read() case and the tls_write() case we fail to
handle errors correctly, which means that error is not reported and can be
lost by a futher libtls call.

ok beck@ jca@

Revision 1.152 / (download) - annotate - [select for diffs], Fri Dec 16 17:44:59 2016 UTC (7 years, 5 months ago) by krw
Branch: MAIN
Changes since 1.151: +5 -2 lines
Diff to previous 1.151 (colored)

Eliminate some gcc warnings about 'unused variables', mostly by
adding appropriate #ifdef's around declarations.

ok millert@ (with a tweak I will commit separately)

Revision 1.151 / (download) - annotate - [select for diffs], Thu Dec 8 19:59:51 2016 UTC (7 years, 5 months ago) by millert
Branch: MAIN
Changes since 1.150: +7 -8 lines
Diff to previous 1.150 (colored)

Avoid splitting the "Requesting %s" printf and its trailing newline.
Fixes a missing newline in one place and an extra one later on when
both debug and verbose are set.

Revision 1.150 / (download) - annotate - [select for diffs], Thu Dec 8 19:31:17 2016 UTC (7 years, 5 months ago) by millert
Branch: MAIN
Changes since 1.149: +8 -8 lines
Diff to previous 1.149 (colored)

Avoid printf of a NULL pointer as a string in debug mode.
OK deraadt@

Revision 1.149 / (download) - annotate - [select for diffs], Sat Aug 20 20:18:42 2016 UTC (7 years, 8 months ago) by millert
Branch: MAIN
Changes since 1.148: +5 -3 lines
Diff to previous 1.148 (colored)

Use connect(2) + a connect_wait() function instead of connect_sync(),
similar to the example in connect(2).  OK tedu@

Revision 1.148 / (download) - annotate - [select for diffs], Thu Aug 18 16:23:06 2016 UTC (7 years, 9 months ago) by millert
Branch: MAIN
Changes since 1.147: +2 -4 lines
Diff to previous 1.147 (colored)

Move connect_sync() to util.c and use it when connecting via http
too.  OK sthen@ deraadt@

Revision 1.147 / (download) - annotate - [select for diffs], Fri May 27 15:16:16 2016 UTC (7 years, 11 months ago) by jsing
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0
Changes since 1.146: +1 -5 lines
Diff to previous 1.146 (colored)

Per the libtls man page, tls_init() must be called prior to any other
tls_* function; so actually do that.

Revision 1.146 / (download) - annotate - [select for diffs], Fri May 6 22:06:09 2016 UTC (8 years ago) by jca
Branch: MAIN
Changes since 1.145: +1 -5 lines
Diff to previous 1.145 (colored)

Remove #ifdef INET6 bits, missed in a commit earlier this week

This probably broke passive FTP on IPv6 and [ip::v6]:port syntax in
RAMDISK ftp(1), sorry about that.

The diff was initially ok millert@

Revision 1.138.2.1 / (download) - annotate - [select for diffs], Tue Feb 2 19:47:38 2016 UTC (8 years, 3 months ago) by martijn
Branch: OPENBSD_5_7
Changes since 1.138: +4 -2 lines
Diff to previous 1.138 (colored) next main 1.139 (colored)

Backport fix for crash when non-standard newline is returned.

OK sthen@ and beck@

Revision 1.139.4.1 / (download) - annotate - [select for diffs], Tue Feb 2 19:43:20 2016 UTC (8 years, 3 months ago) by martijn
Branch: OPENBSD_5_8
Changes since 1.139: +4 -2 lines
Diff to previous 1.139 (colored) next main 1.140 (colored)

Backport fix for crash when non-standard newline is returned.

OK sthen@ and beck@

Revision 1.145 / (download) - annotate - [select for diffs], Thu Jan 28 21:31:50 2016 UTC (8 years, 3 months ago) by martijn
Branch: MAIN
CVS Tags: OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.144: +4 -2 lines
Diff to previous 1.144 (colored)

Fix a crash when a server sends a non-standard newline ("\n" instead of "\r\n").
Present since ssl support was initially added in OpenBSD 4.0

Found by sthen@ via github downtime

OK sthen@

Revision 1.144 / (download) - annotate - [select for diffs], Fri Jan 8 20:36:01 2016 UTC (8 years, 4 months ago) by sthen
Branch: MAIN
Changes since 1.143: +7 -2 lines
Diff to previous 1.143 (colored)

Handle redirects to _relative_ URIs containing '://', e.g. for archive.org.
From Lauri Tirkkonen, plus tweak to comment.  ok jung@

Revision 1.143 / (download) - annotate - [select for diffs], Tue Oct 13 08:53:43 2015 UTC (8 years, 7 months ago) by guenther
Branch: MAIN
Changes since 1.142: +4 -3 lines
Diff to previous 1.142 (colored)

ctype functions isxdigit() expect an unsigned char value; add missing casts
and adjust variable types to get correct behavior

ok beck@ millert@

Revision 1.142 / (download) - annotate - [select for diffs], Thu Sep 10 13:43:35 2015 UTC (8 years, 8 months ago) by jsing
Branch: MAIN
Changes since 1.141: +8 -8 lines
Diff to previous 1.141 (colored)

Unbreak ftp(1) after tls_read()/tls_write() change.

Found the hard way by naddy@

Joint work with beck@

Revision 1.141 / (download) - annotate - [select for diffs], Thu Sep 10 10:35:58 2015 UTC (8 years, 8 months ago) by beck
Branch: MAIN
Changes since 1.140: +10 -14 lines
Diff to previous 1.140 (colored)

fix after libtls api changes
ok jsing@

Revision 1.140 / (download) - annotate - [select for diffs], Wed Sep 9 19:23:03 2015 UTC (8 years, 8 months ago) by jsing
Branch: MAIN
Changes since 1.139: +3 -3 lines
Diff to previous 1.139 (colored)

Make sure we check TLS_WRITE_AGAIN when calling tls_read() and if
tls_read() fails, print the tls_error() rather than just the return value.

ok beck@

Revision 1.139 / (download) - annotate - [select for diffs], Sat Jul 18 21:50:47 2015 UTC (8 years, 10 months ago) by bluhm
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE
Branch point for: OPENBSD_5_8
Changes since 1.138: +14 -4 lines
Diff to previous 1.138 (colored)

Handle short writes and TLS_{READ,WRITE}_AGAIN around tls_write().
input doug@; OK beck@

Revision 1.138 / (download) - annotate - [select for diffs], Fri Feb 27 17:38:19 2015 UTC (9 years, 2 months ago) by jca
Branch: MAIN
CVS Tags: OPENBSD_5_7_BASE
Branch point for: OPENBSD_5_7
Changes since 1.137: +5 -3 lines
Diff to previous 1.137 (colored)

Fix URL-encoding of characters with the high order bit set.

Before/after:
127.0.0.1 - - [25/Feb/2015:09:39:24 +0100] "GET /h%ff%ffh%ff%ff.dat HTTP/1.0" 404 162 "-" "OpenBSD ftp"
127.0.0.1 - - [25/Feb/2015:09:39:27 +0100] "GET /h%c3%a9h%c3%a9.dat HTTP/1.0" 200 0 "-" "OpenBSD ftp"

Additionnally, avoid one case of undefined behaviour with ctype.h.

Input from guenther@, ok millert@

Revision 1.137 / (download) - annotate - [select for diffs], Fri Jan 16 06:40:08 2015 UTC (9 years, 4 months ago) by deraadt
Branch: MAIN
Changes since 1.136: +2 -4 lines
Diff to previous 1.136 (colored)

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible.  Annotate <sys/param.h> lines with their current reasons.  Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc.  Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution.  These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)

Revision 1.136 / (download) - annotate - [select for diffs], Mon Jan 12 15:46:55 2015 UTC (9 years, 4 months ago) by bluhm
Branch: MAIN
Changes since 1.135: +25 -9 lines
Diff to previous 1.135 (colored)

Fetching port distfiles with the ftp command from githup did not
work when using a https proxy because of a missing host header.
Remember the host form the url and write it into the http request.
Fix the format string when using Proxy-Authorization together with
Cookie.  Also write the http request to the debugging output to
see what is going on.
input jca@; OK sthen@ mpi@

Revision 1.135 / (download) - annotate - [select for diffs], Tue Nov 25 08:22:09 2014 UTC (9 years, 5 months ago) by deraadt
Branch: MAIN
Changes since 1.134: +5 -1 lines
Diff to previous 1.134 (colored)

set ttyout to line buffered, because the signal handler writes are
non-buffered. They were getting out of order.
from Kaspars Bankovskis, discussion included millert

Revision 1.134 / (download) - annotate - [select for diffs], Fri Oct 31 13:48:21 2014 UTC (9 years, 6 months ago) by jsing
Branch: MAIN
Changes since 1.133: +45 -45 lines
Diff to previous 1.133 (colored)

Update ftp(1) to use libtls instead of libressl.

Revision 1.133 / (download) - annotate - [select for diffs], Thu Oct 30 15:50:50 2014 UTC (9 years, 6 months ago) by tedu
Branch: MAIN
Changes since 1.132: +2 -2 lines
Diff to previous 1.132 (colored)

use ressl constant; from Jan Klemkow

Revision 1.132 / (download) - annotate - [select for diffs], Wed Oct 8 04:01:10 2014 UTC (9 years, 7 months ago) by doug
Branch: MAIN
Changes since 1.131: +2 -2 lines
Diff to previous 1.131 (colored)

userland reallocarray audit.

Replace malloc() and realloc() calls that may have integer overflow in the
multiplication of the arguments with reallocarray().

ok deraadt@

Revision 1.131 / (download) - annotate - [select for diffs], Mon Oct 6 11:47:25 2014 UTC (9 years, 7 months ago) by jca
Branch: MAIN
Changes since 1.130: +7 -8 lines
Diff to previous 1.130 (colored)

Amend previous commit to unbreak TLS cert validation when using a proxy.
ok miod@

Revision 1.130 / (download) - annotate - [select for diffs], Sat Oct 4 15:48:24 2014 UTC (9 years, 7 months ago) by miod
Branch: MAIN
Changes since 1.129: +2 -2 lines
Diff to previous 1.129 (colored)

Be sure to only path the remote host to ressl_connect_socket(), without a
possible :portnumber suffix.
Noticed by ajacoutot@

ok ajacoutot@ deraadt@

Revision 1.129 / (download) - annotate - [select for diffs], Mon Aug 25 15:36:00 2014 UTC (9 years, 8 months ago) by deraadt
Branch: MAIN
Changes since 1.128: +3 -1 lines
Diff to previous 1.128 (colored)

you broke the ramdisk builds...

Revision 1.128 / (download) - annotate - [select for diffs], Mon Aug 25 11:33:55 2014 UTC (9 years, 8 months ago) by jca
Branch: MAIN
Changes since 1.127: +7 -2 lines
Diff to previous 1.127 (colored)

When using a proxy for an https connection, validate the cert hostname
against the target hostname, not the proxy hostname.  Issue reported by
dlg@, fix by Alex Wilson on tech@, tweaks by me.
No reply from tech@

Revision 1.127 / (download) - annotate - [select for diffs], Thu Aug 21 16:46:48 2014 UTC (9 years, 8 months ago) by jca
Branch: MAIN
Changes since 1.126: +1 -2 lines
Diff to previous 1.126 (colored)

Fix double free.  ok guenther@

Revision 1.126 / (download) - annotate - [select for diffs], Mon Jul 14 09:26:27 2014 UTC (9 years, 10 months ago) by jsing
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE, OPENBSD_5_6
Changes since 1.125: +39 -289 lines
Diff to previous 1.125 (colored)

Convert ftp(1) to libressl, rather than rolling in^W^Whand rolling libssl.

ok beck@ deraadt@

Revision 1.125 / (download) - annotate - [select for diffs], Fri Jul 11 18:19:45 2014 UTC (9 years, 10 months ago) by halex
Branch: MAIN
Changes since 1.124: +1 -14 lines
Diff to previous 1.124 (colored)

simplify and slightly tweak user agent handling

ok lteo@

Revision 1.124 / (download) - annotate - [select for diffs], Fri Jul 11 03:31:52 2014 UTC (9 years, 10 months ago) by lteo
Branch: MAIN
Changes since 1.123: +17 -4 lines
Diff to previous 1.123 (colored)

Allow ftp(1) to change its User-Agent for HTTP(S) URL requests using a
-U command-line option.

feedback from deraadt@, halex@, and Adam Thompson
ok deraadt@ sthen@, man page changes ok jmc@

Revision 1.123 / (download) - annotate - [select for diffs], Sat Jul 5 09:20:54 2014 UTC (9 years, 10 months ago) by guenther
Branch: MAIN
Changes since 1.122: +50 -33 lines
Diff to previous 1.122 (colored)

Given an http or https URL with user and password, URL-decode the user
and password info before base64 encoding it for the Authorization header.
Also:
 - eliminate the COOKIE_MAX_LEN constant (if they can fit it on the command
   line or in their environment, surely we can malloc the base64 version)
 - rename the variable with user:pass from "cookie" to "credentials"
 - empty password isn't an error
 - add a boolean ishttpurl so that we don't have to do strcmps on the schema
   that we just set
 - when looping across multiple ftp:// urls on the command line, don't
   leak the username/password memory

problem noted by Se'bastien Marie (semarie-openbsd (at) latrappe.fr)

Revision 1.122 / (download) - annotate - [select for diffs], Tue May 20 01:25:23 2014 UTC (10 years ago) by guenther
Branch: MAIN
Changes since 1.121: +3 -3 lines
Diff to previous 1.121 (colored)

Use errc/warnc to simplify code.
Also, in 'ftp', always put the error message last, after the hostname/ipaddr.

ok jsing@ krw@ millert@

Revision 1.121 / (download) - annotate - [select for diffs], Mon May 19 20:09:22 2014 UTC (10 years ago) by jca
Branch: MAIN
Changes since 1.120: +2 -1 lines
Diff to previous 1.120 (colored)

X509_free() the certificate if the server hostname check fails.
No functional change.  Reported by Mike Small and Maxime Villard.

Revision 1.120 / (download) - annotate - [select for diffs], Mon May 19 20:05:09 2014 UTC (10 years ago) by jca
Branch: MAIN
Changes since 1.119: +3 -3 lines
Diff to previous 1.119 (colored)

Explicitely initialize two static variables introduced in the previous
commit, to please lteo@

Revision 1.119 / (download) - annotate - [select for diffs], Mon May 19 20:03:16 2014 UTC (10 years ago) by jca
Branch: MAIN
Changes since 1.118: +49 -22 lines
Diff to previous 1.118 (colored)

HTTPS connections may see redirects, so initialize libcrypto and libssl
only once, and reuse the crafted SSL_CTX for further connections.
ok lteo@

Revision 1.114.4.1 / (download) - annotate - [select for diffs], Wed Apr 9 20:35:58 2014 UTC (10 years, 1 month ago) by jca
Branch: OPENBSD_5_5
Changes since 1.114: +184 -1 lines
Diff to previous 1.114 (colored) next main 1.115 (colored)

SECURITY fix: the ftp(1) client would fail to check the server hostname
when connecting to an https website. This allowed any trusted CA-signed
certificate to impersonate any other website.  ok sthen@ deraadt@

Revision 1.118 / (download) - annotate - [select for diffs], Wed Apr 9 10:10:57 2014 UTC (10 years, 1 month ago) by jca
Branch: MAIN
Changes since 1.117: +184 -1 lines
Diff to previous 1.117 (colored)

If TLS validation is on, retrieve the server TLS certificate and
check the server hostname against the subjectAltName extension field
and/or the CommonName DN portion.  ok sthen@

Revision 1.117 / (download) - annotate - [select for diffs], Sun Mar 30 22:40:38 2014 UTC (10 years, 1 month ago) by jca
Branch: MAIN
Changes since 1.116: +14 -1 lines
Diff to previous 1.116 (colored)

SNI support.  ok guenther@ sthen@

Revision 1.116 / (download) - annotate - [select for diffs], Sun Mar 30 22:39:42 2014 UTC (10 years, 1 month ago) by jca
Branch: MAIN
Changes since 1.115: +6 -3 lines
Diff to previous 1.115 (colored)

Check the return value from SSL_CTX_set_cipher_list(), for consistency.
ok guenther@ sthen@

Revision 1.115 / (download) - annotate - [select for diffs], Sun Mar 30 22:37:41 2014 UTC (10 years, 1 month ago) by jca
Branch: MAIN
Changes since 1.114: +1 -2 lines
Diff to previous 1.114 (colored)

SSLeay_add_ssl_algorithms() is just a #define for SSL_library_init(), so
kill the former.  ok guenther@ sthen@

Revision 1.114 / (download) - annotate - [select for diffs], Sun Mar 2 17:57:18 2014 UTC (10 years, 2 months ago) by tedu
Branch: MAIN
CVS Tags: OPENBSD_5_5_BASE
Branch point for: OPENBSD_5_5
Changes since 1.113: +2 -2 lines
Diff to previous 1.113 (colored)

only signed types work when comparing less than zero.
reported by matthieu. ok deraadt

Revision 1.113 / (download) - annotate - [select for diffs], Wed Feb 26 20:48:06 2014 UTC (10 years, 2 months ago) by tedu
Branch: MAIN
Changes since 1.112: +6 -5 lines
Diff to previous 1.112 (colored)

use a larger read buffer to speed things up, particularly during upgrades.
ok deraadt

Revision 1.112 / (download) - annotate - [select for diffs], Tue Dec 24 13:00:59 2013 UTC (10 years, 4 months ago) by jca
Branch: MAIN
Changes since 1.111: +21 -2 lines
Diff to previous 1.111 (colored)

Add support for SSL/TLS server certificate validation, enabled by
default.  See the documentation for the `-S' switch.  This also allows
setting the preferred ciphers for the communication.  Documentation bits
ok'ed by jmc@, ok beck@ sthen@.

Revision 1.111 / (download) - annotate - [select for diffs], Wed Nov 13 20:41:10 2013 UTC (10 years, 6 months ago) by deraadt
Branch: MAIN
Changes since 1.110: +2 -2 lines
Diff to previous 1.110 (colored)

satisfy gcc in -Whiny mode

Revision 1.110 / (download) - annotate - [select for diffs], Sun Oct 27 18:31:24 2013 UTC (10 years, 6 months ago) by guenther
Branch: MAIN
Changes since 1.109: +2 -2 lines
Diff to previous 1.109 (colored)

If a constant string needs a name, use a static const array instead of a
pointer or non-const array, as that minimizes the symbols, maximizes the
placement into read-only memory, and avoids warnings from gcc -Wformat=2
when they're used as format strings.

ok deraadt@

Revision 1.109 / (download) - annotate - [select for diffs], Tue Apr 9 08:58:46 2013 UTC (11 years, 1 month ago) by sthen
Branch: MAIN
CVS Tags: OPENBSD_5_4_BASE, OPENBSD_5_4
Changes since 1.108: +12 -4 lines
Diff to previous 1.108 (colored)

Retry when SSL_read fails with SSL_ERROR_WANT_READ. Fixes the case where
an https server attempts renegotiation. ok jung@

Revision 1.108 / (download) - annotate - [select for diffs], Sat Mar 30 10:11:35 2013 UTC (11 years, 1 month ago) by tobias
Branch: MAIN
Changes since 1.107: +2 -1 lines
Diff to previous 1.107 (colored)

Fixed a memory leak during HTTP header parsing.

ok deraadt, halex, sthen

Revision 1.107 / (download) - annotate - [select for diffs], Sat Aug 18 06:46:46 2012 UTC (11 years, 9 months ago) by haesbaert
Branch: MAIN
CVS Tags: OPENBSD_5_3_BASE, OPENBSD_5_3
Changes since 1.106: +6 -3 lines
Diff to previous 1.106 (colored)

Fix http resume without out auth, which I broke on the last commit,
spotted by bluhm.

ok bluhm.

Revision 1.106 / (download) - annotate - [select for diffs], Tue Aug 14 20:47:08 2012 UTC (11 years, 9 months ago) by haesbaert
Branch: MAIN
Changes since 1.105: +41 -12 lines
Diff to previous 1.105 (colored)

Add support for basic HTTP authentication as described on RFC 2617 and
RFC 3986. This allows the following idiom in ftp:

ftp http[s]://user:pass@host/file

With some pointers from halex a lot of testing and feedback from lteo,
thanks a lot.

ok lteo@

Revision 1.105 / (download) - annotate - [select for diffs], Mon Apr 30 13:41:26 2012 UTC (12 years ago) by haesbaert
Branch: MAIN
CVS Tags: OPENBSD_5_2_BASE, OPENBSD_5_2
Changes since 1.104: +38 -4 lines
Diff to previous 1.104 (colored)

Add a -s flag to ftp(1) to let the user specify the source IP address
of the connection. This is useful for testing ftp(1) over VPN tunnels.

This -s flag is present in the other BSDs, including OS X.

All work was done by Lawrence Teo, thanks (-:.

ok myself mikeb

Revision 1.104 / (download) - annotate - [select for diffs], Mon Apr 23 21:22:02 2012 UTC (12 years ago) by sthen
Branch: MAIN
Changes since 1.103: +4 -1 lines
Diff to previous 1.103 (colored)

Handle HTTP Content-Length headers with trailing whitespace. ok martynas@

Revision 1.103 / (download) - annotate - [select for diffs], Wed Aug 25 20:32:37 2010 UTC (13 years, 8 months ago) by martynas
Branch: MAIN
CVS Tags: OPENBSD_5_1_BASE, OPENBSD_5_1, OPENBSD_5_0_BASE, OPENBSD_5_0, OPENBSD_4_9_BASE, OPENBSD_4_9
Changes since 1.102: +1 -3 lines
Diff to previous 1.102 (colored)

don't free proxyurl and cookie twice in the location code;  with halex@

Revision 1.102 / (download) - annotate - [select for diffs], Fri Jul 23 22:27:16 2010 UTC (13 years, 9 months ago) by halex
Branch: MAIN
CVS Tags: OPENBSD_4_8_BASE, OPENBSD_4_8
Changes since 1.101: +70 -14 lines
Diff to previous 1.101 (colored)

Handle redirection to relative url's in the Location: header of http
responses. Yes, they are violating the rfc's. Yes they do exist anyway.

Also fix a memory leak when url_encode fails to malloc, by simply
err'ing out if so.

feedback and ok phessler@

Revision 1.101 / (download) - annotate - [select for diffs], Sat Jul 3 00:21:14 2010 UTC (13 years, 10 months ago) by halex
Branch: MAIN
Changes since 1.100: +2 -1 lines
Diff to previous 1.100 (colored)

make lint happy

ok phessler@

Revision 1.100 / (download) - annotate - [select for diffs], Tue Jun 29 23:12:33 2010 UTC (13 years, 10 months ago) by halex
Branch: MAIN
Changes since 1.99: +4 -4 lines
Diff to previous 1.99 (colored)

fix output handling:
- if a remote file by the name '-' is retrieved, that does not imply
  it should go to standard output...
- make -o '' reset any previous -o action
- properly handle multiple -o 's

ok phessler@

Revision 1.99 / (download) - annotate - [select for diffs], Thu Jun 3 07:50:02 2010 UTC (13 years, 11 months ago) by halex
Branch: MAIN
Changes since 1.98: +2 -2 lines
Diff to previous 1.98 (colored)

HTTP/1.1 requests must send a "Connection: close" header. Fixes the issue where
a download would stall at the end of the file for no apparent reason.

ok sthen@, phessler@

Revision 1.98 / (download) - annotate - [select for diffs], Thu Jun 3 07:39:53 2010 UTC (13 years, 11 months ago) by phessler
Branch: MAIN
Changes since 1.97: +12 -1 lines
Diff to previous 1.97 (colored)

When attempting to resume a download, against an HTTP server that
doesn't support resume, we restart the download from the beginning, like
all other browsers.

Diagnosed by sthen and halex, comment from sthen
OK sthen@, halex@

Revision 1.97 / (download) - annotate - [select for diffs], Fri Oct 16 12:28:04 2009 UTC (14 years, 7 months ago) by martynas
Branch: MAIN
CVS Tags: OPENBSD_4_7_BASE, OPENBSD_4_7
Changes since 1.96: +18 -4 lines
Diff to previous 1.96 (colored)

factor psummary code of ftp.c to be generic, for all types of
transfers.  makes output between all transfers consistent;  handles
SIGINFO for non-ftp transfers too;  shows statistics at the end:
7303400 bytes received in 96.00 seconds (74.29 KB/s)
tweak / ok halex@, sthen@.

Revision 1.96 / (download) - annotate - [select for diffs], Wed Aug 26 11:54:31 2009 UTC (14 years, 8 months ago) by sthen
Branch: MAIN
Changes since 1.95: +2 -2 lines
Diff to previous 1.95 (colored)

In "auto-fetch" mode without -o, the filename to save under is derived
from the URL. In cases where the URL supplied on the command-line returned
an HTTP redirection, ftp(1) was changing the filename to one derived from
the redirected URL. Change this to always use a name derived from the
command-line URL.

Avoids unexpected behaviour with URI-encoded redirection URLs as seen
by matecocido on misc@, and avoids surprises when the redirection is
to an unexpected filename. No change when -o is used.

ok martynas@ deraadt@ "I totally approve" halex@

Revision 1.95 / (download) - annotate - [select for diffs], Thu Aug 6 23:33:35 2009 UTC (14 years, 9 months ago) by martynas
Branch: MAIN
Changes since 1.94: +76 -5 lines
Diff to previous 1.94 (colored)

encode special or unsafe characters defined by rfc1738.  as a result,
- urls passed to ftp containing special characters or unsafe
characters (like, spaces, <>"#{}|\^~[]`%) work
- redirects containing special characters or unsafe characters
(like, spaces, <>"#{}|\^~[]`%) work
reported & tested by ian@ (can fetch a distfile from sourceforge now)
feedback + ok tedu@ & sthen@

Revision 1.94 / (download) - annotate - [select for diffs], Mon Aug 3 21:34:54 2009 UTC (14 years, 9 months ago) by martynas
Branch: MAIN
Changes since 1.93: +4 -4 lines
Diff to previous 1.93 (colored)

tweak error message.  url is valid per rfc1738 and can now be
fetchable with -o.  so point to it too.  requested by chris@
ok sthen@.  better halex@

Revision 1.93 / (download) - annotate - [select for diffs], Mon Jul 27 23:11:26 2009 UTC (14 years, 9 months ago) by martynas
Branch: MAIN
Changes since 1.92: +22 -12 lines
Diff to previous 1.92 (colored)

- make urls such as http://foo, http://foo/, or http://foo/bar/
fetchable, if -o outfile is passed.  outfile will be used as a local
filename
- fix a bug where 'no file after host' code path never got entered;
consider no file after dir invalid;  as code intended
proxy help&ok halex@;  testing(including proxies,pkg_add)&ok sthen@;
looks good to millert@

Revision 1.92 / (download) - annotate - [select for diffs], Sat Jul 18 12:43:30 2009 UTC (14 years, 10 months ago) by jsg
Branch: MAIN
Changes since 1.91: +2 -2 lines
Diff to previous 1.91 (colored)

Don't assign NULL to an integer type, use 0 instead.
No binary change.

Revision 1.91 / (download) - annotate - [select for diffs], Mon Jun 29 09:58:40 2009 UTC (14 years, 10 months ago) by halex
Branch: MAIN
CVS Tags: OPENBSD_4_6_BASE, OPENBSD_4_6
Changes since 1.90: +2 -2 lines
Diff to previous 1.90 (colored)

Fix the range of a #ifndef SMALL ... #endif not to include the "break;"
needed not to make a status of 200 (OK) fall through to the redirect
handling.

This was not noticed since the later code would ignore the isredirect
flag unless it also received a "Location: " header.

ok martynas@

Revision 1.90 / (download) - annotate - [select for diffs], Sat Jun 13 20:01:10 2009 UTC (14 years, 11 months ago) by martynas
Branch: MAIN
Changes since 1.89: +14 -16 lines
Diff to previous 1.89 (colored)

- stat is not fatal, since we want resume not to fail for non-existent
file transfers in all cases
- do it a bit earlier and use HTTP/1.0 if we won't send the range header
- change resume -> restart_point where it is intended
ok halex@, millert@

Revision 1.89 / (download) - annotate - [select for diffs], Thu Jun 4 23:37:09 2009 UTC (14 years, 11 months ago) by halex
Branch: MAIN
Changes since 1.88: +5 -3 lines
Diff to previous 1.88 (colored)

silently ignore -a if a username is supplied in the url

"looks sensible" deraadt@, "fine by me" martynas@

also removed an indeed misplaced/outdated comment per martynas@ request

Revision 1.88 / (download) - annotate - [select for diffs], Thu Jun 4 20:58:34 2009 UTC (14 years, 11 months ago) by martynas
Branch: MAIN
Changes since 1.87: +4 -2 lines
Diff to previous 1.87 (colored)

set anonftp a little later;  in autofetcher itself.  after we
actually know that that login is not provided in url;  and we should
guess it.  fixes a bug reported by halex@ where it tried to login
as 'ftp' after unsuccessful logins;  ok theo, halex@, krw@

Revision 1.87 / (download) - annotate - [select for diffs], Sun May 10 21:45:52 2009 UTC (15 years ago) by martynas
Branch: MAIN
Changes since 1.86: +4 -3 lines
Diff to previous 1.86 (colored)

couple of fixes for fetch:
- don't spam ftp server with four anonftp logins;  if ftp_login has
already failed in setpeer we give up.  also makes install script
nicer;  req'd by theo
- fix autologin = no case which never really worked in fetch since
it did not check for autologin before logging in...
part 1: ok theo, krw@
part 2: "looks right" millert@, ok sthen@

Revision 1.86 / (download) - annotate - [select for diffs], Tue May 5 19:35:30 2009 UTC (15 years ago) by martynas
Branch: MAIN
Changes since 1.85: +7 -1 lines
Diff to previous 1.85 (colored)

make it clean removing the ifdef SMALL maze.  separate cmds and
small stuff.  make it a fetcher.  shrinks quite a bit
agreed by millert@, krw@
ok theo, sthen@

Revision 1.85 / (download) - annotate - [select for diffs], Mon Apr 27 21:37:13 2009 UTC (15 years ago) by deraadt
Branch: MAIN
Changes since 1.84: +1 -5 lines
Diff to previous 1.84 (colored)

toast the rcsid strings which just get in the way

Revision 1.84 / (download) - annotate - [select for diffs], Sun Apr 26 21:26:03 2009 UTC (15 years ago) by martynas
Branch: MAIN
Changes since 1.83: +6 -6 lines
Diff to previous 1.83 (colored)

figure out titles automatically by using remote file name.  remove
-T and just show titles by default for non-verbose transfers;
discussed with, ok theo, sthen@

Revision 1.83 / (download) - annotate - [select for diffs], Thu Oct 16 23:15:53 2008 UTC (15 years, 7 months ago) by martynas
Branch: MAIN
CVS Tags: OPENBSD_4_5_BASE, OPENBSD_4_5
Changes since 1.82: +5 -4 lines
Diff to previous 1.82 (colored)

- resume http transfers [-C], if local file does not exist
- resume ftp transfers [-C, reget, mget], if local file does not
exist
ok theo

Revision 1.82 / (download) - annotate - [select for diffs], Thu Oct 16 21:23:49 2008 UTC (15 years, 7 months ago) by deraadt
Branch: MAIN
Changes since 1.81: +6 -4 lines
Diff to previous 1.81 (colored)

use O_CREAT in -C mode too, for in case it is not there the first time
from frantisek holop, ok millert

Revision 1.81 / (download) - annotate - [select for diffs], Fri Sep 26 11:11:59 2008 UTC (15 years, 7 months ago) by espie
Branch: MAIN
Changes since 1.80: +26 -12 lines
Diff to previous 1.80 (colored)

support proxies with password.
adapted from a patch by nikns, with tweaks by millert.

took forever to test for real...

okay miod@, henning@, millert@

Revision 1.80 / (download) - annotate - [select for diffs], Tue Jul 8 21:07:57 2008 UTC (15 years, 10 months ago) by martynas
Branch: MAIN
CVS Tags: OPENBSD_4_4_BASE, OPENBSD_4_4
Changes since 1.79: +12 -2 lines
Diff to previous 1.79 (colored)

- add support for recursive transfers (but not for floppies), e.g.
'mget -cr 4.*' would recursively fetch (-r), and resume the previous
transfers (-c) of 4.X release directories
uses local matching (fnmatch), but only for recursive transfers.
current behavior is not changed in any way.
- while here, ifndef SMALL debugging stuff, this saves some space,
for floppies
- some debugging code was enabled for non-debugging mode, checks
assume debug is set to zero, but it's not initially set
- all "Confirm with" prompts are forced, remove redundant argument
- fix usage: -C and -c are not available for SMALL

discussed a year ago w/ pyr@
looks good to millert@
previous version looked good to pyr@
man page tweaks & ok jmc@

Revision 1.79 / (download) - annotate - [select for diffs], Thu Jun 26 05:42:20 2008 UTC (15 years, 10 months ago) by ray
Branch: MAIN
Changes since 1.78: +2 -9 lines
Diff to previous 1.78 (colored)

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@

Revision 1.78 / (download) - annotate - [select for diffs], Wed Jun 25 21:15:19 2008 UTC (15 years, 10 months ago) by martynas
Branch: MAIN
Changes since 1.77: +43 -35 lines
Diff to previous 1.77 (colored)

in resume mode, pass -c to mget when {dir,file}hasglob, so that i'm
able to continue multiple transfers with -C;  ok millert@
while here fix some comments (!SMALL vs. SMALL stuff), and add
missing

Revision 1.77 / (download) - annotate - [select for diffs], Sun Jun 15 04:43:20 2008 UTC (15 years, 11 months ago) by martynas
Branch: MAIN
Changes since 1.76: +3 -3 lines
Diff to previous 1.76 (colored)

accept empty password, since that's exactly what rfc1738 tells us
to do;  theo agrees, millert oks

Revision 1.76 / (download) - annotate - [select for diffs], Sun Jun 15 03:11:28 2008 UTC (15 years, 11 months ago) by martynas
Branch: MAIN
Changes since 1.75: +4 -3 lines
Diff to previous 1.75 (colored)

in debug mode (-d), hide password in the same way as command() does;
ok millert@

Revision 1.75 / (download) - annotate - [select for diffs], Mon Nov 26 12:39:00 2007 UTC (16 years, 5 months ago) by martynas
Branch: MAIN
CVS Tags: OPENBSD_4_3_BASE, OPENBSD_4_3
Changes since 1.74: +81 -9 lines
Diff to previous 1.74 (colored)

implement -C for continuing ftp, http(s), and file transfers
ok millert@, pyr@

Revision 1.74 / (download) - annotate - [select for diffs], Wed Jun 13 13:52:26 2007 UTC (16 years, 11 months ago) by pyr
Branch: MAIN
CVS Tags: OPENBSD_4_2_BASE, OPENBSD_4_2
Changes since 1.73: +18 -7 lines
Diff to previous 1.73 (colored)

Enable cookie support. This allows parsing of netscape-like cookie jars
and sending of appropriate cookies. No retrieval of new cookies is done.
Careful review and lots of input by millert and ray.

ok millert@, ray@

Revision 1.73 / (download) - annotate - [select for diffs], Tue Apr 17 14:58:51 2007 UTC (17 years, 1 month ago) by drahn
Branch: MAIN
Changes since 1.72: +34 -4 lines
Diff to previous 1.72 (colored)

Support proxies which require a password just like ftp servers accept passwords
based on code from Florent Thoumie, ok millert@

Revision 1.72 / (download) - annotate - [select for diffs], Thu Feb 8 03:19:12 2007 UTC (17 years, 3 months ago) by ray
Branch: MAIN
CVS Tags: OPENBSD_4_1_BASE, OPENBSD_4_1
Changes since 1.71: +3 -3 lines
Diff to previous 1.71 (colored)

Remove double semicolons.

From Pierre Riteau <pierre dot riteau at free dot fr>.

OK jaredy@ and moritz@.

Revision 1.71 / (download) - annotate - [select for diffs], Sat Feb 3 05:18:40 2007 UTC (17 years, 3 months ago) by ray
Branch: MAIN
Changes since 1.70: +3 -2 lines
Diff to previous 1.70 (colored)

Plug memory leak.

OK otto@.

Revision 1.70 / (download) - annotate - [select for diffs], Mon Sep 25 18:59:59 2006 UTC (17 years, 7 months ago) by deraadt
Branch: MAIN
Changes since 1.69: +4 -3 lines
Diff to previous 1.69 (colored)

You forgot about -DSMALL and broke all the install media

Revision 1.69 / (download) - annotate - [select for diffs], Mon Sep 25 10:18:39 2006 UTC (17 years, 7 months ago) by jsg
Branch: MAIN
Changes since 1.68: +21 -6 lines
Diff to previous 1.68 (colored)

Support some additional HTTP redirect codes.
"looks good" pedro, fgsch, ok otto

Revision 1.68 / (download) - annotate - [select for diffs], Fri Jul 7 12:00:25 2006 UTC (17 years, 10 months ago) by ray
Branch: MAIN
CVS Tags: OPENBSD_4_0_BASE, OPENBSD_4_0
Changes since 1.67: +5 -5 lines
Diff to previous 1.67 (colored)

Remove extraneous code:
 - Instead of generating the same string twice using printf,
   generate once and reuse.
 - Use err instead of errx with strerror.

OK otto@

Revision 1.67 / (download) - annotate - [select for diffs], Fri Jun 23 20:35:25 2006 UTC (17 years, 10 months ago) by steven
Branch: MAIN
Changes since 1.66: +6 -10 lines
Diff to previous 1.66 (colored)

free and sl_free already check against NULL, remove a few unneeded ifs.

ok otto

Revision 1.66 / (download) - annotate - [select for diffs], Thu Jun 1 22:42:11 2006 UTC (17 years, 11 months ago) by ray
Branch: MAIN
Changes since 1.65: +6 -5 lines
Diff to previous 1.65 (colored)

Remove two unnecessary strlen() calls.  Also, check if asprintf
returns -1 instead of checking if connstr == NULL.

OK beck@, moritz@

Revision 1.65 / (download) - annotate - [select for diffs], Thu May 25 03:48:23 2006 UTC (17 years, 11 months ago) by ray
Branch: MAIN
Changes since 1.64: +15 -7 lines
Diff to previous 1.64 (colored)

No matter how big the buffer size is, always limit to INT_MAX for
SSL connections, due to SSL_read()'s prototype.  This allows us to
change ftp_read to return size_t and have it return (0) on error,
just like fread().

OK otto@, beck@

Revision 1.64 / (download) - annotate - [select for diffs], Thu May 25 03:45:25 2006 UTC (17 years, 11 months ago) by ray
Branch: MAIN
Changes since 1.63: +3 -3 lines
Diff to previous 1.63 (colored)

Don't recalculate string length, just use return value from vasprintf.
While here, remove pointless void pointer cast.

OK otto@, beck@

Revision 1.63 / (download) - annotate - [select for diffs], Thu May 25 03:43:36 2006 UTC (17 years, 11 months ago) by ray
Branch: MAIN
Changes since 1.62: +3 -4 lines
Diff to previous 1.62 (colored)

Minor type correction.

OK otto@

Revision 1.62 / (download) - annotate - [select for diffs], Tue May 16 23:43:16 2006 UTC (18 years ago) by ray
Branch: MAIN
Changes since 1.61: +50 -50 lines
Diff to previous 1.61 (colored)

Remove shadowing variables and properly use /* FALLTHROUGH */
comments.  No binary change.

Found by lint.

OK beck@, deraadt@

Revision 1.61 / (download) - annotate - [select for diffs], Tue May 16 16:20:42 2006 UTC (18 years ago) by deraadt
Branch: MAIN
Changes since 1.60: +243 -22 lines
Diff to previous 1.60 (colored)

https URL support; rototilled by a few people including me; originally
from Rainer_Giedat@genua.de

Revision 1.60 / (download) - annotate - [select for diffs], Tue Apr 25 05:45:20 2006 UTC (18 years ago) by tedu
Branch: MAIN
Changes since 1.59: +2 -2 lines
Diff to previous 1.59 (colored)

two strtol calls that were begging to be converted to strtonum

Revision 1.59 / (download) - annotate - [select for diffs], Mon Apr 3 21:05:14 2006 UTC (18 years, 1 month ago) by uwe
Branch: MAIN
Changes since 1.58: +3 -3 lines
Diff to previous 1.58 (colored)

Ignore http_proxy for file urls; ok millert deraadt

Revision 1.58 / (download) - annotate - [select for diffs], Wed Mar 29 15:54:55 2006 UTC (18 years, 1 month ago) by grunk
Branch: MAIN
Changes since 1.57: +7 -5 lines
Diff to previous 1.57 (colored)

fix fetching zero-length files via proxy.  while there, also fix progress-meter
for files >2GB via proxy.

help and discussion otto@,  ok otto@ mickey@

Revision 1.57 / (download) - annotate - [select for diffs], Wed Feb 1 09:19:07 2006 UTC (18 years, 3 months ago) by otto
Branch: MAIN
CVS Tags: OPENBSD_3_9_BASE, OPENBSD_3_9
Changes since 1.56: +6 -2 lines
Diff to previous 1.56 (colored)

save errno, from Ray Lai in PR 4999.

Revision 1.56 / (download) - annotate - [select for diffs], Fri Aug 5 21:01:53 2005 UTC (18 years, 9 months ago) by fgsch
Branch: MAIN
CVS Tags: OPENBSD_3_8_BASE, OPENBSD_3_8
Changes since 1.55: +4 -5 lines
Diff to previous 1.55 (colored)

when i did the cleanup and switched to http 1.1, i forgot to add chunked
support. while it's being tested switch to 1.0. noticed and tested by nick@.

Revision 1.55 / (download) - annotate - [select for diffs], Mon Jul 18 02:55:59 2005 UTC (18 years, 10 months ago) by fgsch
Branch: MAIN
Changes since 1.54: +30 -33 lines
Diff to previous 1.54 (colored)

some cleanup and on non-proxy operation switch to HTTP 1.1 since we've
using some sort of it for a long time now; shrinks ~200 bytes.
ok by millert@ and sturm@.

Revision 1.54 / (download) - annotate - [select for diffs], Thu Apr 21 05:17:21 2005 UTC (19 years, 1 month ago) by fgsch
Branch: MAIN
Changes since 1.53: +9 -2 lines
Diff to previous 1.53 (colored)

avoid infinite recursion on redirects; From NetBSD but limit set to 10.
deraadt@ ok.

Revision 1.53 / (download) - annotate - [select for diffs], Mon Apr 11 15:16:50 2005 UTC (19 years, 1 month ago) by deraadt
Branch: MAIN
Changes since 1.52: +50 -65 lines
Diff to previous 1.52 (colored)

knf; cloder ok

Revision 1.52 / (download) - annotate - [select for diffs], Tue Apr 5 22:37:00 2005 UTC (19 years, 1 month ago) by henning
Branch: MAIN
Changes since 1.51: +9 -3 lines
Diff to previous 1.51 (colored)

a : in the path is not a port # indicator so don't take ones into
account after the first / behind the hostname, ok jaredy

Revision 1.51 / (download) - annotate - [select for diffs], Thu Sep 16 04:39:16 2004 UTC (19 years, 8 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_3_7_BASE, OPENBSD_3_7
Changes since 1.50: +6 -4 lines
Diff to previous 1.50 (colored)

type corrections and other delinting

Revision 1.50 / (download) - annotate - [select for diffs], Tue Jul 20 03:50:25 2004 UTC (19 years, 10 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_3_6_BASE, OPENBSD_3_6
Changes since 1.49: +9 -20 lines
Diff to previous 1.49 (colored)

ansi; khalek@linuxgamers.net

Revision 1.49 / (download) - annotate - [select for diffs], Sat Feb 28 20:08:38 2004 UTC (20 years, 2 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_3_5_BASE, OPENBSD_3_5
Changes since 1.48: +25 -41 lines
Diff to previous 1.48 (colored)

Open a new connection for each URL given on the command line.

This eliminates problematic 'CWD /' commands that caused interactive
commands and auto fetch commands to occaisonally end up in different
directories, creating problems for the install scripts.

Problematic 'CWD /' commands noticed by deraadt@.

ok millert@.

Revision 1.48 / (download) - annotate - [select for diffs], Tue Dec 16 21:46:22 2003 UTC (20 years, 5 months ago) by deraadt
Branch: MAIN
Changes since 1.47: +4 -4 lines
Diff to previous 1.47 (colored)

for -DSMALL, do not include rcsid[]s

Revision 1.47 / (download) - annotate - [select for diffs], Fri Aug 15 23:13:06 2003 UTC (20 years, 9 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_3_4_BASE, OPENBSD_3_4
Changes since 1.46: +4 -4 lines
Diff to previous 1.46 (colored)

remove extra \n in {warn,err}{,x} calls

Revision 1.46 / (download) - annotate - [select for diffs], Sat Apr 5 17:19:47 2003 UTC (21 years, 1 month ago) by deraadt
Branch: MAIN
Changes since 1.45: +3 -3 lines
Diff to previous 1.45 (colored)

string fixes; ok miod henning

Revision 1.45 / (download) - annotate - [select for diffs], Mon Mar 31 23:04:07 2003 UTC (21 years, 1 month ago) by millert
Branch: MAIN
Changes since 1.44: +6 -4 lines
Diff to previous 1.44 (colored)

Treat empty environment variables the same as NULL.  henning@ OK

Revision 1.44 / (download) - annotate - [select for diffs], Mon Mar 10 06:20:10 2003 UTC (21 years, 2 months ago) by itojun
Branch: MAIN
CVS Tags: OPENBSD_3_3_BASE, OPENBSD_3_3
Changes since 1.43: +7 -6 lines
Diff to previous 1.43 (colored)

correct use of getnameinfo.  PR 3138

Revision 1.43 / (download) - annotate - [select for diffs], Mon Feb 17 18:51:11 2003 UTC (21 years, 3 months ago) by millert
Branch: MAIN
Changes since 1.42: +4 -3 lines
Diff to previous 1.42 (colored)

Fix double free; Brian Poole

Revision 1.42 / (download) - annotate - [select for diffs], Mon Dec 30 23:04:42 2002 UTC (21 years, 4 months ago) by deraadt
Branch: MAIN
Changes since 1.41: +29 -24 lines
Diff to previous 1.41 (colored)

minor KNF

Revision 1.41 / (download) - annotate - [select for diffs], Thu Dec 19 01:52:09 2002 UTC (21 years, 5 months ago) by deraadt
Branch: MAIN
Changes since 1.40: +5 -4 lines
Diff to previous 1.40 (colored)

only do "Trying ..." if verbose

Revision 1.40 / (download) - annotate - [select for diffs], Fri Nov 8 03:30:17 2002 UTC (21 years, 6 months ago) by fgsch
Branch: MAIN
Changes since 1.39: +91 -81 lines
Diff to previous 1.39 (colored)

http redirect support; adapted from NetBSD.

Revision 1.39 / (download) - annotate - [select for diffs], Thu May 30 06:51:46 2002 UTC (21 years, 11 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_3_2_BASE, OPENBSD_3_2
Changes since 1.38: +3 -3 lines
Diff to previous 1.38 (colored)

-4 and -6 options; kanai@big.or.jp; itojun ok

Revision 1.38 / (download) - annotate - [select for diffs], Sat Feb 16 21:27:46 2002 UTC (22 years, 3 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_3_1_BASE, OPENBSD_3_1
Changes since 1.37: +7 -7 lines
Diff to previous 1.37 (colored)

Part one of userland __P removal.  Done with a simple regexp with some minor hand editing to make comments line up correctly.  Another pass is forthcoming that handles the cases that could not be done automatically.

Revision 1.37 / (download) - annotate - [select for diffs], Wed Nov 14 07:59:28 2001 UTC (22 years, 6 months ago) by heko
Branch: MAIN
Changes since 1.36: +72 -5 lines
Diff to previous 1.36 (colored)

o Don't accept URLs with user:pass@ and an extra unencoded @.
  @ should be encoded as %40 for passwords and usernames. @ in
  the pathname portion of the URL is ok.
o decode usernames and passwords as per FTP URL specification.
spotted by krw@, input from krw@ and fgs@
millert@ ok

Revision 1.36 / (download) - annotate - [select for diffs], Sat Oct 27 10:31:27 2001 UTC (22 years, 6 months ago) by heko
Branch: MAIN
Changes since 1.35: +11 -11 lines
Diff to previous 1.35 (colored)

Send User-Agent: OpenBSD ftp to WWW servers and proxies.

``User agents SHOULD include this field with requests'', from RFC 2616:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43

Patch from and problem reported by Diana Eichert <deicher@sandia.gov>
when using proxies with specific browser requirements. Tested by me with
the ports mirror-maker makefile / fetch-all script (with and without a
proxy).

ok millert@

Revision 1.35 / (download) - annotate - [select for diffs], Wed Oct 3 18:49:39 2001 UTC (22 years, 7 months ago) by heko
Branch: MAIN
CVS Tags: OPENBSD_3_0_BASE, OPENBSD_3_0
Changes since 1.34: +25 -8 lines
Diff to previous 1.34 (colored)

o Only send port number in the HTTP request 'Host: ' specification
  if it is non-default (i.e., != 80) to circumvent bugs in
  some broken HTTP servers. naddy@ got hit by this with a port,
  lebel@ spotted the problem.
o Print the HTTP request if debug (the ``-d'' flag) is specified.
millert@ ok

Revision 1.34 / (download) - annotate - [select for diffs], Sat Jun 23 22:48:44 2001 UTC (22 years, 11 months ago) by millert
Branch: MAIN
Changes since 1.33: +7 -12 lines
Diff to previous 1.33 (colored)

remove evil #ifdef __GNUC__ garbage to avoid longjmp clobbering and use volatile instead

Revision 1.30.2.1 / (download) - annotate - [select for diffs], Fri Oct 6 21:16:13 2000 UTC (23 years, 7 months ago) by jason
Branch: OPENBSD_2_7
Changes since 1.30: +3 -3 lines
Diff to previous 1.30 (colored) next main 1.31 (colored)

Pull in patch from current (even more to come):
Fix (millert):
warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant).  These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).

Revision 1.33 / (download) - annotate - [select for diffs], Fri Jun 30 16:00:15 2000 UTC (23 years, 10 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_2_9_BASE, OPENBSD_2_9, OPENBSD_2_8_BASE, OPENBSD_2_8
Changes since 1.32: +3 -3 lines
Diff to previous 1.32 (colored)

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant).  These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).

Revision 1.32 / (download) - annotate - [select for diffs], Thu May 25 16:09:26 2000 UTC (23 years, 11 months ago) by itojun
Branch: MAIN
Changes since 1.31: +29 -16 lines
Diff to previous 1.31 (colored)

do not attach incorrect Host: directive if we are using proxy.
Host: directive must be based on original URI, not the proxy address.
see RFC2616.

Revision 1.31 / (download) - annotate - [select for diffs], Mon May 15 16:07:04 2000 UTC (24 years ago) by itojun
Branch: MAIN
Changes since 1.30: +57 -38 lines
Diff to previous 1.30 (colored)

parse RFC2732 ftp URL (ftp://[::1]:21/readme)

Revision 1.30 / (download) - annotate - [select for diffs], Wed May 3 19:50:41 2000 UTC (24 years ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_2_7_BASE
Branch point for: OPENBSD_2_7
Changes since 1.29: +12 -2 lines
Diff to previous 1.29 (colored)

if no /etc/services file, use defaults. found by millert, fixed by itojun

Revision 1.29 / (download) - annotate - [select for diffs], Tue May 2 00:54:53 2000 UTC (24 years ago) by itojun
Branch: MAIN
Changes since 1.28: +16 -6 lines
Diff to previous 1.28 (colored)

always attach port in numeric, for HTTP Host: header.
from: chris and mickey
XXX Host: header is specified in HTTP/1.1, not HTTP/1.0.

Revision 1.28 / (download) - annotate - [select for diffs], Mon Apr 24 03:30:16 2000 UTC (24 years, 1 month ago) by itojun
Branch: MAIN
Changes since 1.27: +20 -5 lines
Diff to previous 1.27 (colored)

support RFC2732 IPv6 address literal URLs (http://[::1]:80/index.html).

Revision 1.27 / (download) - annotate - [select for diffs], Sun Jan 9 05:14:38 2000 UTC (24 years, 4 months ago) by millert
Branch: MAIN
Changes since 1.26: +7 -5 lines
Diff to previous 1.26 (colored)

Make 'ftp host:/path/to/file' work again.  This got broken during IPV6
integration.

Revision 1.26 / (download) - annotate - [select for diffs], Tue Jan 4 17:15:12 2000 UTC (24 years, 4 months ago) by deraadt
Branch: MAIN
Changes since 1.25: +5 -5 lines
Diff to previous 1.25 (colored)

fix file:// URL support; broken by KAME support

Revision 1.25 / (download) - annotate - [select for diffs], Wed Dec 8 12:57:06 1999 UTC (24 years, 5 months ago) by itojun
Branch: MAIN
Changes since 1.24: +58 -65 lines
Diff to previous 1.24 (colored)

ftp(1) from KAME, should be good for testing.

Revision 1.24 / (download) - annotate - [select for diffs], Tue Feb 9 03:43:48 1999 UTC (25 years, 3 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_2_6_BASE, OPENBSD_2_6, OPENBSD_2_5_BASE, OPENBSD_2_5
Changes since 1.23: +8 -2 lines
Diff to previous 1.23 (colored)

if we read less than Content-Length, whine and error

Revision 1.23 / (download) - annotate - [select for diffs], Wed Sep 30 07:49:36 1998 UTC (25 years, 7 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_2_4_BASE, OPENBSD_2_4
Changes since 1.22: +9 -6 lines
Diff to previous 1.22 (colored)

something was too verboase in http fetch mode

Revision 1.22 / (download) - annotate - [select for diffs], Mon Sep 28 13:38:22 1998 UTC (25 years, 7 months ago) by deraadt
Branch: MAIN
Changes since 1.21: +124 -17 lines
Diff to previous 1.21 (colored)

first cut at file:/ URL support

Revision 1.21 / (download) - annotate - [select for diffs], Fri Sep 11 08:04:24 1998 UTC (25 years, 8 months ago) by marc
Branch: MAIN
Changes since 1.20: +3 -3 lines
Diff to previous 1.20 (colored)

don't display Retrieving... message unless verbose output desired

Revision 1.20 / (download) - annotate - [select for diffs], Wed May 13 10:46:12 1998 UTC (26 years ago) by deraadt
Branch: MAIN
Changes since 1.19: +2 -9 lines
Diff to previous 1.19 (colored)

oops

Revision 1.19 / (download) - annotate - [select for diffs], Wed May 13 10:42:38 1998 UTC (26 years ago) by deraadt
Branch: MAIN
Changes since 1.18: +34 -5 lines
Diff to previous 1.18 (colored)

try other h_addr_list addresses when connecting, and handle EINTR

Revision 1.18 / (download) - annotate - [select for diffs], Thu Mar 26 03:17:08 1998 UTC (26 years, 2 months ago) by marc
Branch: MAIN
CVS Tags: OPENBSD_2_3_BASE, OPENBSD_2_3
Changes since 1.17: +4 -4 lines
Diff to previous 1.17 (colored)

pass host name with GET request so servers hosting multiple virtual
hosts know to which host the given path applies

Revision 1.17 / (download) - annotate - [select for diffs], Tue Feb 17 23:22:54 1998 UTC (26 years, 3 months ago) by millert
Branch: MAIN
Changes since 1.16: +21 -20 lines
Diff to previous 1.16 (colored)

Add a new option "-o filename" for autofetch mode.  Allows use of
"-" to mean stdout.  This replaces the old (unreliable) hueristic
of checking if stdout is a tty and if not make the output go to stdout.

Revision 1.16 / (download) - annotate - [select for diffs], Thu Sep 11 01:55:15 1997 UTC (26 years, 8 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_2_2_BASE, OPENBSD_2_2
Changes since 1.15: +3 -3 lines
Diff to previous 1.15 (colored)

- Move `parsed_url' label such that the next statement after the label is
  not an "else" (which some strict compilers reject).

- If getlogin() fails fall back on getpwuid(getuid()).

Revision 1.15 / (download) - annotate - [select for diffs], Thu Sep 4 04:37:15 1997 UTC (26 years, 8 months ago) by millert
Branch: MAIN
Changes since 1.14: +6 -6 lines
Diff to previous 1.14 (colored)

Updtaes from NetBSD (lukem)
    bugs fixed:
      * don't interpret '-' or '|' when a local filename is determined from
        the remote name (i.e, in mget, and in get with only one argument).
        This is implemented using an extra argument to recvrequest().
        Fixes a major security hole.
      * clean up memory leak when using globulize()
      * clean up a couple of comments
      * fix wording in TNF copyright

    features added:
      * support for TIS fwtk gate-ftp servers:
        * read defaults from $FTPSERVER && $FTPSERVERPORT
        * start in gate-ftp mode if invoked as 'gate-ftp'
        * toggle or set with 'gate [host [port]]'

Other changes:
    * use symbolic flags in access(2)
    * Use USHRT_MAX, not 0xffff

Revision 1.14 / (download) - annotate - [select for diffs], Fri Jul 25 21:56:20 1997 UTC (26 years, 10 months ago) by millert
Branch: MAIN
Changes since 1.13: +90 -45 lines
Diff to previous 1.13 (colored)

Updates from NetBSD (lukem) include -Wall cleanup.
More -W* cleanup and in_port_t usage by me.

Revision 1.13 / (download) - annotate - [select for diffs], Thu Jul 24 14:22:21 1997 UTC (26 years, 10 months ago) by deraadt
Branch: MAIN
Changes since 1.12: +15 -14 lines
Diff to previous 1.12 (colored)

no content-length is OK; cato@ulysses.df.lth.se

Revision 1.12 / (download) - annotate - [select for diffs], Mon May 19 05:36:56 1997 UTC (27 years ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_2_1_BASE, OPENBSD_2_1
Changes since 1.11: +5 -3 lines
Diff to previous 1.11 (colored)

Make ftp ftp://anonymous:root@your.dom.ain@ftp.our.place.foo/pub/OpenBSD/
work.  Needed for install scripts to work.  I didn't run into this as
I was installing from a non-anonymous account.

Revision 1.11 / (download) - annotate - [select for diffs], Mon Apr 28 21:10:06 1997 UTC (27 years ago) by millert
Branch: MAIN
Changes since 1.10: +13 -13 lines
Diff to previous 1.10 (colored)

From NetBSD (lukem):
  Cleanup parser of ftp://[user:pass@]host[:port]/[dir/][file
  Should be more robust now.  Fixes NetBSD PR #3520.

Revision 1.10 / (download) - annotate - [select for diffs], Wed Apr 23 20:33:06 1997 UTC (27 years, 1 month ago) by deraadt
Branch: MAIN
Changes since 1.9: +43 -29 lines
Diff to previous 1.9 (colored)

allow "ftp -aV ftp://host/foo.tar.gz | tar xvfpz -" to work

Revision 1.9 / (download) - annotate - [select for diffs], Fri Apr 18 18:56:49 1997 UTC (27 years, 1 month ago) by millert
Branch: MAIN
Changes since 1.8: +7 -7 lines
Diff to previous 1.8 (colored)

Fix problem when fetching files with -a.

Revision 1.8 / (download) - annotate - [select for diffs], Wed Apr 16 05:02:48 1997 UTC (27 years, 1 month ago) by millert
Branch: MAIN
Changes since 1.7: +62 -31 lines
Diff to previous 1.7 (colored)

Sync with NetBSD (lukem):
 * differentiate between being connected, and being logged in
 * cleanup some text messages
 * support username & password ftp URLs (ftp://user:pass@host/) in non-proxy
   situations; assume proxy supports it for proxy situations.
 * cd to / before performing any autofetch transfers

Revision 1.7 / (download) - annotate - [select for diffs], Mon Apr 14 00:48:44 1997 UTC (27 years, 1 month ago) by millert
Branch: MAIN
Changes since 1.6: +8 -8 lines
Diff to previous 1.6 (colored)

URL specifiers are case insensitive.  Noticed by Theo.

Revision 1.6 / (download) - annotate - [select for diffs], Thu Apr 10 00:17:08 1997 UTC (27 years, 1 month ago) by millert
Branch: MAIN
Changes since 1.5: +53 -32 lines
Diff to previous 1.5 (colored)

Sync with NetBSD (lukem)
    * support $ftp_proxy for ftp:// transfers [bin/3245]
    * add "more" & "less" as synonyms for "page"
    * move editline setup code into controlediting(), and call appropriately.
      only setup setup terminal if going into interactive mode.

Revision 1.5 / (download) - annotate - [select for diffs], Fri Mar 21 20:59:29 1997 UTC (27 years, 2 months ago) by millert
Branch: MAIN
Changes since 1.4: +5 -5 lines
Diff to previous 1.4 (colored)

Add in recent NetBSD changes we didn't already have:
    Always compile complete.c but ifdef out the bits if -DSMALL (christos)
    reset interactive mode correctly in auto_fetch() mget mode (lukem)

Revision 1.4 / (download) - annotate - [select for diffs], Fri Mar 14 04:32:14 1997 UTC (27 years, 2 months ago) by millert
Branch: MAIN
Changes since 1.3: +38 -8 lines
Diff to previous 1.3 (colored)

Sync with NetBSD and fix "get foo.txt /dev/tty" wrt progress meter
and setting times.

Revision 1.3 / (download) - annotate - [select for diffs], Wed Feb 5 04:55:16 1997 UTC (27 years, 3 months ago) by millert
Branch: MAIN
Changes since 1.2: +7 -5 lines
Diff to previous 1.2 (colored)

Include signal.h where reasonable and make signal handlers match
what signal(3)'s prototype says (and cast when not).
Also change MAXFOO+1 -> MAXFOO since MAXFOO includes the NULL.
Support $TMPDIR and use utime(3) not utimes(2) for portability's sake.
Don't spew "Passive mode enabled/disabled" unless verbose (this means
togglevar() needs to watch for a NULL 'message').

Revision 1.2 / (download) - annotate - [select for diffs], Mon Feb 3 01:05:37 1997 UTC (27 years, 3 months ago) by millert
Branch: MAIN
Changes since 1.1: +18 -17 lines
Diff to previous 1.1 (colored)

Add back ``-r'' option and fix strncpy() usage and other nits because
I'm anal.  Closer to KNF now.

Revision 1.1 / (download) - annotate - [select for diffs], Mon Feb 3 01:02:37 1997 UTC (27 years, 3 months ago) by millert
Branch: MAIN

Sync with NetBSD

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.