Commit Graph

48 Commits

Author SHA1 Message Date
Duncan Overbruck
d8d284d7c8
lib/fetch: return 0 if buffer len is 0 and buf is NULL
Previously it would return -1 when xbps would download an empty files.
2022-07-19 15:19:01 +02:00
Duncan Overbruck
93186276ee
lib/fetch: don't abort connect(2) attempts on EINVAL 2022-07-19 14:50:29 +02:00
Juan RP
46b7057d91
Fix signed vs unsigned char issues found by NetBSD. 2021-06-26 17:13:01 +02:00
Duncan Overbruck
51b39002e5
Revert "Move all external code to lib/external."
This reverts commit 9effec0c4e.
2021-02-04 22:42:57 +01:00
Juan RP
9effec0c4e
Move all external code to lib/external. 2020-04-24 12:32:09 +02:00
Juan RP
35ae128826
lib/fetch: fix CID 284966 in a different way.
Hopefully this fixes it for real.
2020-04-20 10:31:13 +02:00
Juan RP
8663c3bd75
lib/fetch/common.c: fix CID 284959 (NULL returns).
Also fix previous CID.
2020-04-19 11:53:28 +02:00
Juan RP
359721baa6
lib/fetch/common.c: fix CID 284966 (Resource leak). 2020-04-19 11:43:54 +02:00
Piotr Wójcik
5737d9a941 xbps-fetch: TIMEOUT_CONNECTION to customize time waiting for response 2020-03-03 08:15:00 +01:00
Johannes Brechtmann
11e5190a36 lib/fetch: happy_eyeballs_connect check for waiting connections before
decrementing them, remove dead code
2019-06-23 12:14:21 +02:00
Duncaen
7e762cc357 lib/fetch.c: ignore EADDRNOTAVAIL and try next ip 2019-06-21 20:23:55 +02:00
Duncaen
093950dba2 lib/fetch: remove port from happy eyeballs verbose logs, wrong cast and redundant 2019-06-20 13:28:14 +02:00
Duncaen
81a736a5ac lib/fetch: cleanup happy eyeballs and add verbose logging 2019-06-20 12:15:30 +02:00
Duncaen
a3af0e5559 lib/fetch: remember if ipv6 or ipv4 are unreachable and don't try to connect again 2019-06-20 11:32:12 +02:00
Juan RP
fd88298755 lib/fetch/common.c: fix memleak in happy_eyeballs_connect.
Found by clang-analyzer.

Bug Summary

File: lib/fetch/common.c
Warning: line 587, column 4
Potential leak of memory pointed to by 'pfd'
2019-06-18 18:49:29 +02:00
Duncaen
104e8393f3 lib/fetch: fix happy eyeballs without any usable addresses and catch more errors 2019-06-15 19:19:40 +02:00
Duncaen
8018833010 lib/fetch: add FORCE_IPV{4,6} environment variables 2019-06-15 19:19:40 +02:00
Andreas Kempe
0c657582f2 lib/fetch/common.c: send socks5 request as a single transaction
Splitting the socks5 request is causing issues when running against Tor.
It causes Tor to fail with an address unknown error. Assembling the
request and sending it in its entirety solves the issue.

An strace of torsocks, that functions correctly when used with xbps, shows
that the request is being sent all at once:

        recvfrom(3, "\5\0", 2, 0, NULL, NULL)
        sendto(3, "\5\1\0\3>lysator7eknrfl47rlyxvgeamrv7ucefgrrlhk7rouv3sna25asetwid.onion\0P", 69, 0, NULL, 0)
        recvfrom(3, "\5\0\0\1\0\0\0\0\0\0", 10, 0, NULL, NULL)

Closes: #54 [via git-merge-pr]
2019-04-20 11:11:40 +02:00
Duncaen
9f52a7837f lib/fetch: add happy eyeballs connect algorithm (RFC6555/RFC8305)
Connect to the addresses from `getaddrinfo(3)`,
alternating between address family,
starting with ipv6 and wait `fetchConnDelay`
between each connection attempt.

If a connection is established within the attempts,
use this connection and close all others.

If `connect(3)` returns `ENETUNREACH`, don't attempt more
connections with the failing address family.

If there are no more addresses to attempt,
wait for `fetchConnTimeout` and return the first established
connection.

If no connection was established within the timeouts,
close all sockets and return -1 and set errno to
`ETIMEDOUT`.
2019-04-19 22:58:50 +02:00
wuhanck
b4eebafa6d upgrade to openssl 1.1.x. 2019-01-24 14:57:50 -05:00
Duncaen
08b9ed878f lib/fetch: default port, error checks and authentication support 2016-09-02 17:50:05 +02:00
Duncaen
30ace44394 lib/fetch: add socks5 support 2016-09-01 00:38:55 +02:00
Michael Gehring
46744c412d lib/fetch/common.c: fix build with -Werror=misleading-indentation
Fixes #179
2016-06-03 20:26:52 +02:00
Juan RP
adcc6d16a4 lib/fetch/common.c: simplify ssl_init(). 2016-04-24 19:20:54 +02:00
Juan RP
eb3d227d61 lib/fetch: check that SSL_CTX_new() does not fail and print its errors (#170).
Thanks @ebfe.
2016-04-24 08:42:32 +02:00
Juan RP
b810c25601 lib/fetch/common.c: dup pthread.h inclusion. 2016-04-23 07:04:25 +02:00
Juan RP
e2e8eea490 lib/fetch: also call SSL_load_error_strings() once (#167).
Close #168
2016-04-22 11:38:01 +02:00
Juan RP
228a89d51e Use pthread_once(3) to initialize openssl/libressl just once.
Fixes openssl initialization concurrently by multiple threads.
Close #167
2016-04-22 11:32:34 +02:00
Michael Gehring
0f56b68eac add HAVE_STRNSTR 2016-02-08 15:09:33 +01:00
Juan RP
9e524d831c fetch/common.c: fix a memleak found by clang-analyzer. 2015-12-21 17:12:14 +01:00
Juan RP
f4cb178f6c libfetch: use default CA path rather than default CA file.
The default CA file set by FreeBSD is only available when using the
LibreSSL provided CA file, and we've decided to use the CA path
by default.

Discussed with @dominikh.
2015-10-28 07:31:26 +01:00
Juan RP
90eb1d9433 libfetch: merge some features from FreeBSD:
- Supports HTTP/1.1 308 redirect.
- SSLv[23] HTTPS connections are forbidden by default.
- TLS client certificate validation thru OpenSSL.
- Fixes for user/password encoding, misc.
2015-10-24 07:52:30 +02:00
Juan RP
b513a5e15e libfetch: misc cleanups due to nbcompat removal. 2014-12-28 03:34:36 +01:00
Juan RP
4ee6f943dd libfetch: fix races in the cache connection code.
Tested by @Gottox.
2014-12-23 10:52:54 +01:00
Juan RP
a6cdd9a698 lib/fetch/common.c: CID 62709 (NULL pointer dereference) 2014-10-07 11:07:24 +02:00
Juan RP
25e8fca7b4 lib/fetch/common.c: fix CID 62681 correctly (resource leak). 2014-10-05 10:21:18 +02:00
Juan RP
c1959b3915 lib/fetch/common.c: resource leak (CID 62681) 2014-10-05 09:08:05 +02:00
Juan RP
25e8002737 fetch: hardcode HTTPS port and fallback to /etc/services for other unknown ports. 2014-08-25 16:07:47 +02:00
Juan RP
510c84d3bb libfetch: synchronized with NetBSD's pkgsrc/libfetch, preserving our changes. 2014-06-29 10:29:36 +02:00
Juan RP
be1ef74ba2 libfetch: merge NetBSD's common.c 1.29 too to reduce differences and fix a warning. 2014-06-29 10:04:07 +02:00
Juan RP
7bb36ddaa2 libfetch: fetch_close: make sure conn->ssl is valid before shutting down. 2014-06-28 12:12:03 +02:00
Juan RP
633c20a2e6 libfetch: merge TLS SNI support from NetBSD with some other random changes.
Close GH #41
2014-06-28 12:01:00 +02:00
Juan RP
5eea259c13 Remove the config.h kludge and override vasprintf detection via HAVE_VASPRINTF. 2014-01-20 18:50:33 +01:00
Juan RP
42ba861e21 lib/fetch: ignore -Wformat-nonliteral with clang. 2013-07-02 08:54:02 +02:00
Juan RP
2f3913f3aa lib/fetch/common.c: merge 2.34 and backport a patch for select(2) and SSL. 2013-01-13 21:09:15 +01:00
Juan RP
bd37736d89 Import and merge libfetch-2.31 from NetBSD pkgsrc. 2010-06-02 23:44:25 +02:00
Juan RP
03e8fa53d9 Merge libfetch-2.30 from NetBSD's pkgsrc.
--HG--
extra : convert_revision : xtraeme%40gmail.com-20100124144753-ni487x8m7r05847b
2010-01-24 15:47:53 +01:00
Juan RP
7aebea684b Implemented support for working with remote repositories.
libfetch from NetBSD's pkgsrc has been imported into lib/fetch, but
the objects are embedded into libxbps. Only a public function to fetch
files has been implemented: xbps_fetch_file().

The library now is built with -fvisibility=hidden by default, and
exported symbols are the ones that use the SYMEXPORT macro.

The code works well enough, but will need many more cleanups.

--HG--
extra : convert_revision : xtraeme%40gmail.com-20091027004600-0lq9aao67lisbzxv
2009-10-27 01:46:00 +01:00