Commit Graph

209 Commits

Author SHA1 Message Date
des
6a7fe6e363 Don't forget to set the error flag when _fetch_read() returns -1. 2002-10-30 04:42:01 +00:00
imp
3fe448f373 Reinstate revs 1.35-36 and 1.38. Revisions 1.34 and 1.37 were specifically
the root cause of the bus errors I was experiencing.

Submitted by:	fenner
Tested by:	obrien
Prompted by:	peter
2002-10-30 00:17:16 +00:00
obrien
04ec43bef2 Fix `pkg_add -r' by backing out revs 1.34-1.38.
Revs 1.37-8 produce a bus error in some environments.
Revs 1.34-6 do not bus error, but write corrupted files.
2002-10-29 12:17:43 +00:00
des
610f30442d libfetch is now WARNS5 clean in the non-SSL case. 2002-10-28 10:37:31 +00:00
des
82217d5553 Fix an off-by-one error (> where >= should have been used) which caused
_fetch_writev() to incorrectly report EPIPE in certain cases.

Also fix a number of const warnings by using __DECONST(), plus a signed /
unsigned comparison by casting the rhs to ssize_t.

Submitted by:	fenner, Craig Rodrigues <rodrigc@attbi.com>
2002-10-28 10:19:03 +00:00
fenner
9a1f47baa2 Up WARNS to 3 if not building with crypto.
Approved by:	des
2002-10-28 01:41:28 +00:00
des
da4ac4fa83 Slight amendment to rev 1.34: instead of considering any short read an
error, only report an error if no data was read at all (unless len was
0 to start with).  Otherwise, the final read of practically any transfer
will end in a fatal error.
2002-10-27 17:20:49 +00:00
des
a68f827727 Introduce _fetch_writev(), which is the conn_t version of writev(2). In
the SSL case, it is no different from the old _fetch_write(), but in the
non-SSL case it uses writev(2) to send the entire vector as a single
packet (provided it can fit in one packet).  Implement _fetch_write()
and _fetch_putln() in terms of _fetch_writev().

This should improve performance in the non-SSL case (by reducing protocol
overhead) and solve the problem where too-smart-for-their-own-good
firewalls reject FTP packets that do not end in CRLF.

PR:		bin/44123
Submitted by:	fenner
2002-10-27 16:11:21 +00:00
des
3b29692357 Eliminate two cases of undefined behaviour: total in _fetch_write() was
not initialized before use, and _http_growbuf() did not return a value
on success.

Reported by:	Peter Edwards <pmedwards@eircom.net>
MFC after:	2 weeks
2002-10-27 15:43:40 +00:00
des
8e68b07af2 Back out the previous commit, and fix the bug rather than try to hide its
symptoms: make timeouts and short transfers fatal, and set errno to an
appropriate value (ETIMEDOUT for a timeout, EPIPE for a short transfer).

MFC after:	2 weeks
2002-10-27 15:08:21 +00:00
njl
0717b726b4 The FTP connection caching needs a better interface -- connections are
closed through _fetch_close() which is the only one who knows the connection
REALLY was closed (since ref -> 0).  However, FTP keeps its own local
cached_connection and checks if it is valid by comparing it to NULL.  This
is bogus since it may have been freed elsewhere by _fetch_close().

This change checks if we are closing the cached_connection and the ref is 1
(soon to be 0).  If so, set cached_connection to NULL so we don't
accidentally reuse it.  The REAL fix should be to move connection caching
to the common.c level (_fetch_* functions) and NULL the cache(s) in
_fetch_close().  Then all layers could benefit from caching.
2002-10-25 01:17:32 +00:00
obrien
ac60a6ce40 Use a warns setting we can catch regressions with. 2002-10-20 23:50:28 +00:00
tjr
b668a00bc9 When recycling a cached connection, increment the reference count so that
the heap block does not get freed and reused. This should fix the
pkg_add -r crashes that have been happening for months.
2002-10-20 10:36:27 +00:00
ru
374aac0ec5 HTTP authentication got broken in rev. 1.49. 2002-10-03 10:42:19 +00:00
peter
8d8b96d08c Zap now-unused SHLIB_MINOR 2002-09-28 00:25:32 +00:00
alfred
b674d88a4e Fix an infinite loop when _fetch_read() can return 0 (if the
connection is broken), take this into account and return at this
point.
2002-09-20 21:50:57 +00:00
fenner
8c3e434ca5 Make _fetch_connect() always set the error code.
Tell ftp that _fetch_connect() always sets the error code (http already knew)
2002-09-17 05:54:33 +00:00
des
91003b4607 Surround prototypes with __BEGIN_DECLS / __END_DECLS.
PR:		misc/40399
MFC after:	3 days
2002-07-22 16:11:39 +00:00
ume
74bff649e9 Cope with 2292bis-01 getaddrinfo (no NI_WITHSCOPEID, always attach
scope identifier).

Approved by:	des
MFC after:	3 weeks
2002-07-02 11:09:02 +00:00
des
bbbe649263 Reintroduce debugging code that somehow got lost in a previous revision. 2002-06-24 12:18:41 +00:00
des
16360548ce Fix incorrect library ordering. I thought I'd committed this already... 2002-06-21 09:56:38 +00:00
des
b4b7fe8695 Don't try to dereference conn when we know it's NULL. 2002-06-19 08:36:00 +00:00
des
0c268b1caa Add a reference count to struct fetchconn so we don't prematurely close and
free a cached FTP connection.
2002-06-11 11:27:28 +00:00
ru
30074c9c9b libfetch now depends on libcrypto and libssl. 2002-06-06 13:45:46 +00:00
des
75745ae764 Make SSL support conditional on NOCRYPT. 2002-06-05 21:35:35 +00:00
des
a754ec65e4 During buildworld, "regular" libraries are built before crypto stuff, so
libfetch can't depend on lib{crypto,ssl}.  Move the dependency to fetch
until we can figure out how to fix this.
2002-06-05 21:25:33 +00:00
des
5b7d9aaf87 Add SSL support + slight cleanup.
Submitted by:	Henry Whincup <henry@techiebod.com> (in principle)
2002-06-05 12:46:36 +00:00
des
c24b418c46 Wrap everything in struct connection, and enforce timeouts everywhere
(except for DNS operations).  Always use funopen() for HTTP, to support
both timeouts and SSL.
2002-06-05 12:19:08 +00:00
des
571aca999f Add the necessary dependencies for SSL. 2002-06-05 11:38:19 +00:00
des
004a5250d6 Rename struct cookie to struct httpio to avoid confusion (it's not an HTTP
cookie) and increase symmetry with equivalent FTP code.
2002-06-05 10:31:01 +00:00
des
6941ef681f Add comments to struct cookie. 2002-06-05 10:27:24 +00:00
des
76e30e953a Fix a bug I introduced in the chunk decoder in the previous commit.. 2002-06-05 10:23:19 +00:00
des
4f6928d2f9 First step towards SSL support: wrap connections in a 'struct connection'
which contains the socket descriptor, the input buffer and (yet unused)
SSL state variables.  This has the neat side effect of greatly improving
reentrance (though we're not *quite* there yet) and opening the door to
HTTP connection caching.

This commit is inspired by email conversations with and patches from
Henry Whincup <henry@techiebod.com> last fall.
2002-06-05 10:05:03 +00:00
markm
146609ba72 Do not use __progname directly (except in [gs]etprogname(3)).
Also, make an internal _getprogname() that is used only inside
libc. For libc, getprogname(3) is a weak symbol in case a
function of the same name is defined in userland.
2002-03-29 22:43:43 +00:00
phk
191c10a907 Modernize my email address 2002-03-25 13:53:46 +00:00
des
6428d00171 Switch to a self-starting allocation scheme. 2002-02-05 22:15:16 +00:00
des
562afadccd Reindent, and add parentheses to return statements. Some functions in
ftp.c and http.c now have exceedingly long lines due to deep nesting;
this will be corrected by reorganizing the code in a later revision.
2002-02-05 22:13:51 +00:00
des
819f582fa9 Eliminate a redundant loop. 2002-02-05 21:32:16 +00:00
des
a27767b078 Check the return value from read() when reading the CR/LF at the end of a
chunk.

PR:		bin/33608
MFC after:	2 weeks
2002-01-20 19:53:12 +00:00
des
11272fd27d Mark uploads as O_WRONLY, not O_RDONLY.
PR:		misc/34043
MFC after:	2 weeks
2002-01-20 19:52:25 +00:00
des
bc717d3322 Remove long-obsolete README. 2002-01-01 16:27:26 +00:00
des
7c44538231 In verbose mode, display the full error message from the server, stripping
it of HTML tags and comments.

PR:		bin/32989
MFC after:	1 week
2002-01-01 16:25:29 +00:00
des
ac2d3d0a70 Remove VT100 escapes from debugging messages now that they're enabled by
default.

PR:		32988
MFC after:	3 days
2002-01-01 14:48:09 +00:00
des
94d767623c Don't build with NDEBUG.
PR:		bin/32615
MFC after:	1 week
2001-12-09 15:06:38 +00:00
des
1fecd8709a Conditionalize some debugging code that didn't use the DEBUG macro.
MFC after:	1 week
2001-12-09 15:05:58 +00:00
des
3726695d3c Introduce a fetchDebug global. Change the DEBUG macro so it only runs the
debugging code if fetchDebug is set.

PR:		bin/32615
MFC after:	1 week
2001-12-09 15:05:19 +00:00
des
539218484b Properly handle being redirected to an FTP URL.
Also fix a couple of not-so-minor bugs:
 - missing case for HTTP_SEE_OTHER
 - incorrect definition of HTTP_NEED_PROXY_AUTH

PR:		20259
MFC after:	2 weeks
2001-12-04 01:12:51 +00:00
des
66c3bcef50 Add prototype for _ftp_request(). 2001-12-04 01:10:34 +00:00
des
c7b3de766e Reorganize to reduce code duplication. 2001-12-04 01:09:19 +00:00
des
940b0b81db Add NO_WERROR so the build won't die because of discarded qualifiers 2001-10-19 10:08:38 +00:00