summaryrefslogtreecommitdiff
path: root/lib/libfetch
Commit message (Collapse)AuthorAgeFilesLines
* Remove support for SSLv3 from fetch(3).Jung-uk Kim2020-11-242-9/+3
| | | | | | | | | Support for SSLv3 was already removed from OpenSSL (r361392). Differential Revision: https://reviews.freebsd.org/D24947 Notes: svn path=/head/; revision=368000
* Replace literal uses of /usr/local in C sources with _PATH_LOCALBASEStefan Eßer2020-10-271-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Literal references to /usr/local exist in a large number of files in the FreeBSD base system. Many are in contributed software, in configuration files, or in the documentation, but 19 uses have been identified in C source files or headers outside the contrib and sys/contrib directories. This commit makes it possible to set _PATH_LOCALBASE in paths.h to use a different prefix for locally installed software. In order to avoid changes to openssh source files, LOCALBASE is passed to the build via Makefiles under src/secure. While _PATH_LOCALBASE could have been used here, there is precedent in the construction of the path used to a xauth program which depends on the LOCALBASE value passed on the compiler command line to select a non-default directory. This could be changed in a later commit to make the openssh build consistently use _PATH_LOCALBASE. It is considered out-of-scope for this commit. Reviewed by: imp MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D26942 Notes: svn path=/head/; revision=367075
* Don't explicitly specify c99 or gnu99 as the default is now gnu99.Xin LI2020-08-171-2/+0
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=364292
* fetch(3): plug some leaksKyle Evans2020-02-211-1/+5
| | | | | | | | | | | | | | In the successful case, sockshost is not freed prior to return. The failure case can now be hit after fetch_reopen(), which was not true before. Thus, we need to make sure to clean up all of the conn resources which will also close sd. For all of the points prior to fetch_reopen(), we continue to just close sd. CID: 1419598, 1419616 Notes: svn path=/head/; revision=358227
* fetch(3): don't leak sockshost on failureKyle Evans2020-02-151-10/+13
| | | | | | | | | | | fetch_socks5_getenv will allocate memory for the host (or set it to NULL) in all cases through the function; the caller is responsible for freeing it if we end up allocating. While I'm here, I've eliminated a label that just jumps to the next line... Notes: svn path=/head/; revision=357979
* fetch(3): fix regression in IPv6:port spec from r357977Kyle Evans2020-02-151-5/+5
| | | | | | | | | | In case the port was specified, we never actually populated *host. Do so now. Pointy hat: kevans Notes: svn path=/head/; revision=357978
* fetch(3): move bits of fetch_socks5_getenv aroundKyle Evans2020-02-151-36/+32
| | | | | | | | | This commit separates out port parsing and validation from grabbing the host from the env var. The only related bit really is that we need to be more specific with the delimiter in the IPv6 case. Notes: svn path=/head/; revision=357977
* fetch(3): Add SOCKS5 supportKyle Evans2020-02-153-11/+351
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change adds SOCKS5 support to the library fetch(3) and updates the man page. Details: Within the fetch_connect() function, fetch(3) checks if the SOCKS5_PROXY environment variable is set. If so, it connects to this host rather than the end-host. It then initializes the SOCKS5 connection in accordance with RFC 1928 and returns the resulting conn_t (file descriptor) for usage by the regular FTP/HTTP handlers. Design Decision: This change defaults all DNS resolutions through the proxy by sending all IPs as hostnames. Going forward, another feature might be to create another environmental variable to toggle resolutions through the proxy or not.. One may set the SOCKS5_PROXY environment variable in any of the formats: SOCKS5_PROXY=proxy.example.com SOCKS5_PROXY=proxy.example.com:1080 SOCKS5_PROXY=192.0.2.0 SOCKS5_PROXY=198.51.100.0:1080 SOCKS5_PROXY=[2001:db8::1] SOCKS5_PROXY=[2001:db8::2]:1080 Then perform a request with fetch(1). (note by kevans) I've since been informed that Void Linux/xbps has a fork of libfetch that also implements SOCKS5. I may compare/contrast the two in the mid-to-near future. Submitted by: Farhan Khan <farhan farhan codes> Differential Revision: https://reviews.freebsd.org/D18908 Notes: svn path=/head/; revision=357968
* libfetch: disallow invalid escape sequencesEd Maste2020-02-051-0/+3
| | | | | | | | | | | Per RFC1738 escape is "% hex hex"; other sequences do not form a valid URL. Suggested by: Matthew Dillon Reviewed by: Matthew Dillon MFC after: 1 week Notes: svn path=/head/; revision=357579
* Fix urldecode buffer overrun.Gordon Tetlow2020-01-281-2/+8
| | | | | | | | Reported by: Duncan Overbruck Security: CVE-2020-7450 Notes: svn path=/head/; revision=357212
* Update Makefile.depend filesSimon J. Gerraty2019-12-111-3/+0
| | | | | | | | | | | | | Update a bunch of Makefile.depend files as a result of adding Makefile.depend.options files Reviewed by: bdrewery MFC after: 1 week Sponsored by: Juniper Networks Differential Revision: https://reviews.freebsd.org/D22494 Notes: svn path=/head/; revision=355617
* Add Makefile.depend.optionsSimon J. Gerraty2019-12-111-0/+9
| | | | | | | | | | | | | | | | | | | | Leaf directories that have dependencies impacted by options need a Makefile.depend.options file to avoid churn in Makefile.depend DIRDEPS for cases such as OPENSSL, TCP_WRAPPERS etc can be set in local.dirdeps-options.mk which can add to those set in Makefile.depend.options See share/mk/dirdeps-options.mk Reviewed by: bdrewery MFC after: 1 week Sponsored by: Juniper Networks Differential Revision: https://reviews.freebsd.org/D22469 Notes: svn path=/head/; revision=355616
* pkgbase: Create a FreeBSD-utilities package and make it the default oneEmmanuel Vadot2019-09-051-1/+0
| | | | | | | | | | | | | The default package use to be FreeBSD-runtime but it should only contain binaries and libs enough to boot to single user and repair the system, it is also very handy to have a package that can be tranform to a small mfsroot. So create a new package named FreeBSD-utilities and make it the default one. Also move a few binaries and lib into this package when it make sense. Reviewed by: bapt, gjb Differential Revision: https://reviews.freebsd.org/D21506 Notes: svn path=/head/; revision=351858
* Document fetchReqHTTP().Mark Johnston2019-08-283-3/+23
| | | | | | | | | | Submitted by: Farhan Khan <khanzf@gmail.com> Reviewed by: 0mp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D18788 Notes: svn path=/head/; revision=351573
* [libfetch] Fix compilation with WITHOUT_CRYPT.Adrian Chadd2019-05-031-0/+1
| | | | Notes: svn path=/head/; revision=347050
* When deciding whether to send the complete URL or just the document part,Dag-Erling Smørgrav2018-11-271-1/+1
| | | | | | | | | | | | we were looking at the original URL rather than the one we were currently processing. This meant that if we were trying to retrieve an HTTP URL but were redirected to an HTTPS URL, and HTTPS proxying was enabled, we would send an invalid request and most likely get garbage back. MFC after: 3 days Notes: svn path=/head/; revision=341072
* A few more cases where strcasecmp() is no longer required.Dag-Erling Smørgrav2018-11-271-4/+4
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=341014
* Improve URL parsing. In particular, convert scheme and host to lowercase.Dag-Erling Smørgrav2018-11-273-43/+56
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=341013
* Support proxying FTP over HTTPS, not just HTTP.Dag-Erling Smørgrav2018-11-271-1/+2
| | | | | | | | | | | There is probably a PR for this, but I can't find this, or remember who submitted it. The patch got lost in the noise of another that wasn't ready to commit. MFC after: 3 days Notes: svn path=/head/; revision=341011
* Make libfetch buildable.Jung-uk Kim2018-09-191-0/+4
| | | | Notes: svn path=/projects/openssl111/; revision=338779
* Fix an inverted conditional in the netrc code, which would ignore theDag-Erling Smørgrav2018-05-293-14/+34
| | | | | | | | | | | | value of $HOME and always use the home directory from the passwd database, unless $HOME was unset, in which case it would use (null). While there, clean up handling of netrcfd and add debugging aids. MFC after: 3 weeks Notes: svn path=/head/; revision=334326
* Fix a few (but far from all) style issues.Dag-Erling Smørgrav2018-05-291-24/+29
| | | | | | | MFC after: 3 weeks Notes: svn path=/head/; revision=334319
* Use __VA_ARGS__ to simplify the DEBUG macro.Dag-Erling Smørgrav2018-05-295-51/+52
| | | | | | | MFC after: 3 weeks Notes: svn path=/head/; revision=334317
* Preserve if-modified-since timestamps across redirects.Dag-Erling Smørgrav2018-05-121-0/+1
| | | | | | | | PR: 224426 MFC after: 1 week Notes: svn path=/head/; revision=333571
* SPDX: use the Beerware identifier.Pedro F. Giffuni2017-11-301-1/+1
| | | | Notes: svn path=/head/; revision=326408
* lib: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-267-0/+14
| | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using mis-identified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Notes: svn path=/head/; revision=326219
* DIRDEPS_BUILD: Update dependencies.Bryan Drewery2017-10-311-1/+0
| | | | | | | Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=325188
* In fetch_resolve(), if the port number or service name is included inDag-Erling Smørgrav2017-08-181-1/+1
| | | | | | | | | | | | | | | | the host argument (e.g. "www.freebsd.org:443"), the service pointer, which is supposed to point to the port or service part, instead points to the separator, causing getaddrinfo() to fail. Note that I have not been able to trigger this bug with fetch(1), nor do I believe it is possible, as libfetch always parses the host:port specification itself. I discovered it when I copied fetch_resolve() into an unrelated project. MFC after: 3 days Notes: svn path=/head/; revision=322669
* r308996 broke IP literals by assuming that a colon could only occur asDag-Erling Smørgrav2017-03-173-42/+49
| | | | | | | | | | | | | | | | | | a separator between host and port, and using strchr() to search for it. Rewrite fetch_resolve() so it handles bracketed literals correctly, and remove similar code elsewhere to avoid passing unbracketed literals to fetch_resolve(). Remove #ifdef INET6 so we still parse IP literals correctly even if we do not have the ability to connect to them. While there, fix an off-by-one error which caused HTTP 400 errors to be misinterpreted as redirects. PR: 217723 MFC after: 1 week Reported by: bapt, bz, cem, ngie Notes: svn path=/head/; revision=315455
* Add a __printflike() that would have caught the bug fixed in r314396.Dag-Erling Smørgrav2017-03-121-1/+1
| | | | Notes: svn path=/head/; revision=315143
* libfetch: extra bounds checking through reallocarray(3).Pedro F. Giffuni2017-03-061-1/+1
| | | | | | | | Reviewed by: des MFC after: 1 week Notes: svn path=/head/; revision=314778
* Fix partial requests (used by fetch -r) when the requested file isDag-Erling Smørgrav2017-03-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | already complete. Since 416 is an error code, any Content-Range header in the response would refer to the error message, not the requested document, so relying on the value of size when we know we got a 416 is wrong. Instead, just verify that offset == 0 and assume that we've reached the end of the document (if offset > 0, we did not request a range, and the server is screwing with us). Note that we cannot distinguish between reaching the end and going past it, but that is a flaw in the protocol, not in the code, so we just have to assume that the caller knows what it's doing. A smart caller would request an offset slightly before what it believes is the end and compare the result to what is already in the file. PR: 212065 Reported by: mandree MFC after: 3 weeks Notes: svn path=/head/; revision=314701
* Properly initialize netrcfd in fetchParseURLBaptiste Daroussin2017-03-031-0/+1
| | | | | | | | | | | This fixes ftp with fetch(1) which was broken after r313974 Submitted by: dim Reported by: olivier Pointyhat to: bapt Notes: svn path=/head/; revision=314596
* Properly indent a default: label and avoid crashing when runningBjoern A. Zeeb2017-02-281-2/+2
| | | | | | | | | | under -v but cannot connect due to trying to print an int as %s [1]. Reported by: andrew [1] MFC after: 3 days Notes: svn path=/head/; revision=314396
* Add a file descriptor in struct url for netrcBaptiste Daroussin2017-02-203-9/+23
| | | | | | | | | | | | | | | | When using libfetch in an application that drops privileges when fetching like pkg(8) then user complain because the application does not read anymore ${HOME}/.netrc. Now a caller can prepare a fd to the said file and manually assign it to the structure. It is also a first step to allow to capsicumize libfetch applications Reviewed by: allanjude, des Approved by: des Differential Revision: https://reviews.freebsd.org/D9678 Notes: svn path=/head/; revision=313974
* Fix inverted loop condition which broke multi-line responses to CONNECT.Dag-Erling Smørgrav2016-12-301-1/+1
| | | | | | | | | PR: 194483 Submitted by: Miłosz Kaniewski <milosz.kaniewski@gmail.com> MFC after: 1 week Notes: svn path=/head/; revision=310823
* More debugging code I missed in r309051.Dag-Erling Smørgrav2016-12-091-1/+0
| | | | | | | Reported by: jbeich, jkim Notes: svn path=/head/; revision=309738
* Remove debugging code.Dag-Erling Smørgrav2016-11-231-4/+0
| | | | Notes: svn path=/head/; revision=309051
* Refactor fetch_connect() and fetch_bind() to improve readability and avoidDag-Erling Smørgrav2016-11-223-54/+129
| | | | | | | | | repeating the same DNS lookups. MFC after: 3 weeks Notes: svn path=/head/; revision=308996
* r169386 (PR 112515) was incomplete: it treated 307 as an error exceptDag-Erling Smørgrav2016-05-311-0/+3
| | | | | | | | | | | | | | | | in verbose mode, and did not handle 308 at all. r241840 (PR 172451) added support for 308, but with the same bug. Correctly handle both by recognizing them as redirects in all places where we check the HTTP result code. PR: 112515 173451 209546 Submitted by: novel@ MFC after: 1 week Notes: svn path=/head/; revision=301027
* Call closedir() before returning from fetchListFile() to avoid a leak.Don Lewis2016-05-251-0/+1
| | | | | | | | | Reported by: Coverity CID: 1016697 MFC after: 1 week Notes: svn path=/head/; revision=300666
* Don't leak addrinfo in fetch_bind()Don Lewis2016-05-251-1/+4
| | | | | | | | | Reported by: Coverity CID: 1225038 MFC after: 1 week Notes: svn path=/head/; revision=300665
* Use strlcpy() instead of strncpy() to copy the string returned byDon Lewis2016-05-121-1/+1
| | | | | | | | | | | | | | | setlocale() so that static analyzers know that the string is NUL terminated. This was causing a false positive in Coverity even though the longest string returned by setlocale() is ENCODING_LEN (31) and we are copying into a 64 byte buffer. This change is also a bit of an optimization since we don't need the strncpy() feature of padding the rest of the destination buffer with NUL characters. Reported by: Coverity CID: 974654 Notes: svn path=/head/; revision=299520
* lib: minor spelling fixes in comments.Pedro F. Giffuni2016-05-011-2/+2
| | | | | | | No functional change. Notes: svn path=/head/; revision=298896
* MFHGlen Barber2016-04-111-1/+1
|\ | | | | | | | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/release-pkg/; revision=297824
| * libfetch: replace 0 with NULL for pointers.Pedro F. Giffuni2016-04-091-1/+1
| | | | | | | | | | | | | | | | | | Found with devel/coccinelle. Reviewed by: des Notes: svn path=/head/; revision=297754
* | MFHGlen Barber2016-04-041-11/+17
|\| | | | | | | | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/release-pkg/; revision=297567
| * Fix bunch of .Xrs.Edward Tomasz Napierala2016-03-281-1/+0
| | | | | | | | | | | | | | | | MFC after: 1 month Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=297355
| * Update fetch.1 and fetch.3 to reflect libfetch's actual use of CA bundlesMichael Gmelin2016-03-191-10/+17
| | | | | | | | | | | | | | | | | | | | Reviewed by: wblock Approved by: wblock MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D5558 Notes: svn path=/head/; revision=297052
* | MFHGlen Barber2016-03-021-6/+0
|\| | | | | | | | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/release-pkg/; revision=296318