summaryrefslogtreecommitdiff
path: root/src/util
Commit message (Collapse)AuthorAgeFilesLines
* posix: use WSAPoll on win32Edward Thomson2023-05-132-0/+4
|
* posix: introduce p_poll emulation with selectEdward Thomson2023-05-133-0/+76
| | | | Not all systems have poll(2); emulate it with select(2).
* net: move `gitno` buffer to `staticstr`Edward Thomson2023-05-131-0/+66
| | | | | | | | The `gitno` buffer interface is another layer on top of socket reads. Abstract it a bit into a "static string" that has `git_str` like semantics but without heap allocation which moves the actual reading logic into the socket / stream code, and allows for easier future usage of a static / stack-allocated `git_str`-like interface.
* net: move rfc2818 hostname / wildcard matching to utilEdward Thomson2023-05-132-0/+61
|
* util: make monotonic time fn return msEdward Thomson2023-05-132-20/+30
| | | | | | | | | | | | | | | | | `git__timer` is now `git_time_monotonic`, and returns milliseconds since an arbitrary epoch. Using a floating point to store the number of seconds elapsed was clever, as it better supports the wide range of precision from the different monotonic clocks of different systems. But we're a version control system, not a real-time clock. Milliseconds is a good enough precision for our work _and_ it's the units that system calls like `poll` take and that our users interact with. Make `git_time_monotonic` return the monotonically increasing number of milliseconds "ticked" since some arbitrary epoch.
* Merge pull request #6561 from libgit2/ethomson/xdiffEdward Thomson2023-05-131-0/+2
|\ | | | | Update xdiff to git 2.40.1's version
| * util: add GIT_UNUSED_ARGEdward Thomson2023-05-111-0/+2
| | | | | | | | | | Add `GIT_UNUSED_ARG` which is an attribute for arguments, for compatibility with dependencies.
* | Merge pull request #6558 from DimitryAndric/fix-qsort-variants-2Edward Thomson2023-05-122-14/+16
|\ \ | |/ |/| Work around -Werror problems when detecting qsort variants
| * cmake: simplify QSORT namesEdward Thomson2023-05-122-14/+16
| | | | | | | | `QSORT_R` and `QSORT_S` -> `QSORT`
* | Merge pull request #6557 from libgit2/ethomson/shallowEdward Thomson2023-05-092-6/+14
|\ \ | |/ |/| Shallow (#6396) with some fixes from review
| * oid: use an oid array instead of shallowarrayEdward Thomson2023-05-091-0/+3
| | | | | | | | | | | | Users should provide us an array of object ids; we don't need a separate type. And especially, we should not be mutating user-providing values. Instead, use `git_oid *` in the shallow code.
| * futils: use SHA256 for checksums alwaysEdward Thomson2023-05-081-5/+8
| | | | | | | | | | | | | | | | Use SHA256 for file checksums. SHA1 makes no sense as a default in 2023. Given that we're just looking at a file checksum to see if it's changed, this does not need to take repository's OID type into account or otherwise be configurable.
| * Merge remote-tracking branch 'origin/main' into shallow-clone-networkEdward Thomson2023-04-2212-110/+193
| |\
| * \ Merge commit 'd066d0d95c43e97df6624292f3f527f9372ca8fe'lmcglash2023-03-1015-533/+395
| |\ \
| * | | Merge branch 'transportPR' into shallow-clone-networkyuangli2022-07-291-1/+3
| | | |
* | | | util: detect all possible qsort_r and qsort_s variantsDimitry Andric2023-05-082-8/+12
| |_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As reported in https://bugs.freebsd.org/271234, recent versions of FreeBSD have adjusted the prototype for qsort_r() to match the POSIX interface. This causes libgit2's CMake configuration check to fail to detect qsort_r(), making it fall back to qsort_s(), which in libgit2 also has an incompatible interface. With recent versions of clang this results in a "incompatible function pointer types" compile error. Summarizing, there are four variations of 'qsort-with-context': * old style BSD qsort_r(), used in FreeBSD 13 and earlier, where the comparison function has the context parameter first * GNU or POSIX qsort_r(), also used in FreeBSD 14 and later, where the comparison function has the context parameter last * C11 qsort_s(), where the comparison function has the context parameter last * Microsoft qsort_s(), where the comparison function has the context parameter first Add explicit detections for all these variants, so they get detected as (in the same order as above): * `GIT_QSORT_R_BSD` * `GIT_QSORT_R_GNU` * `GIT_QSORT_S_C11` * `GIT_QSORT_S_MSC` An additional complication is that on FreeBSD 14 and later, <stdlib.h> uses the C11 _Generic() macro mechanism to automatically select the correct qsort_r() prototype, depending on the caller's comparison function argument. This breaks CMake's check_prototype_definition() functionality, since it tries to redefine the function, and _Generic macro is expanded inline causing a compile error. Work around that problem by putting the function names in parentheses, to prevent the preprocessor from using a macro to replace the function name. Also, in `git__qsort_r()`, change the `#if` order so the variants that do not have to use glue are preferred.
* | | filebuf: configurable hash typeEdward Thomson2023-04-082-7/+25
| | | | | | | | | | | | | | | | | | `git_filebuf` hashes contents as its written; allow for SHA1 or SHA256 as that hash. Currently, most callers simply use SHA1 as they do not yet know about SHA256 themselves.
* | | utf8: add conversion with size and refactor namesEdward Thomson2023-03-218-102/+167
| | | | | | | | | | | | | | | | | | | | | | | | Add functions to use convert a string with length, instead of assuming NUL termination. In addition, move the utf8 to 16 conversion routines into the `git_utf8` namespace instead of using namespaceless `git__` prefixed names.
* | | http: introduce schannel streams for windowsEdward Thomson2023-03-211-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Provide a stream interface for Schannel - the native crypto APIs - on Windows. This allows Windows to use the same HTTP transport that all the other platforms use, with its own native crypto. Ultimately this allows us to deprecate WinHTTP and we need not add support for our socket changes in two places (our HTTP stack and the WinHTTP stack).
* | | cmake: don't include `include/git2`Edward Thomson2023-03-101-1/+0
| |/ |/| | | | | | | Including the `include/git2` build path is a seemingly unnecessary oversight to include the generated `experimental.h` file.
* | net: parse urls or scp style paths in the same functionEdward Thomson2023-02-242-0/+13
| |
* | repo: don't fail on strange win32 pathsEdward Thomson2023-02-181-1/+1
| | | | | | | | | | | | | | With some paths on Win32, we cannot identify the owner because it's on a file share (WSL2 or UNC). In that case, don't fail, but identify that the current user does not own the path. This matches Git for Windows behavior.
* | Merge pull request #6456 from libgit2/ethomson/sha256_experimentalEdward Thomson2023-02-141-0/+13
|\ \ | | | | | | SHA256: more SHA256 support
| * | transport: teach transports about oid types and SHA256Edward Thomson2023-02-121-0/+13
| | |
* | | Merge pull request #6455 from libgit2/ethomson/sysdirEdward Thomson2023-02-143-311/+0
|\ \ \ | | | | | | | | Support the notion of a home directory separately from global configuration directory
| * | | sysdir: move windows sysdir functions out of shared utilEdward Thomson2023-02-093-311/+0
| |/ / | | | | | | | | | | | | | | | The windows sysdir functions are libgit2-specific and for git compatibility only; remove them from the shared util directory and bring them into the libgit2 source tree.
* | | Merge pull request #6376 from bzEq/bzEq/aix-int64Edward Thomson2023-02-141-0/+2
|\ \ \ | | | | | | | | Define correct off64_t for AIX
| * | | Revert "Include <stdint.h>"Kai Luo2022-09-221-1/+2
| | | | | | | | | | | | | | | | This reverts commit 1fde70bb607c7ba471db359f045affd1f5625e5d.
| * | | Include <stdint.h>Kai Luo2022-09-221-2/+1
| | | |
| * | | On AIX, `off64_t` is equivalent to `long long`.Kai Luo2022-08-091-0/+2
| | |/ | |/| | | | | | | See `/usr/include/sys/types.h` on AIX.
* | | openssl: support OpenSSL 3 in dynamic modeEdward Thomson2023-02-101-3/+4
| |/ |/| | | | | | | | | | | | | | | Try to load OpenSSL 3 libraries when compiled with OpenSSL-Dynamic support. Handle the deprecated symbol renaming of SSL_get_peer_certificate to SSL_get1_peer_certificate -- try to load the old name and if it fails, use the new one.
* | Add OpenSSL deprection warningEdward Thomson2023-02-021-0/+2
| | | | | | | | | | Add `OPENSSL_API_COMPAT=0x10100000L` since we use the now-deprecated low-level hash functions.
* | hash: drop all declarations from hmacEdward Thomson2023-01-241-114/+0
| | | | | | | | | | | | | | The builtin hash uses the code verbatim from rfc6234, including prototypes for functions that we don't use (like hmac). Remove all unused prototypes to avoid collisions with things that an operating system might provide (like hmac).
* | src: hide unused hmac() prototypeThomas Klausner2023-01-241-0/+2
| | | | | | | | | | | | It conflicts with NetBSD's in its libc. Closes #6457
* | thread: avoid warnings when building without threadsEdward Thomson2022-11-232-19/+21
| | | | | | | | | | | | `git__noop` takes no arguments, so a simple `#define func(a) git__noop` will produce warnings about the unused `a`. Introduce `git__noop_args` to swallow arguments and avoid that warning.
* | Merge pull request #6326 from libgit2/ethomson/url_parseEdward Thomson2022-11-232-84/+332
|\ \ | | | | | | URL parsing for google-compatible URLs
| * | url: only allow @s in usernames for ssh urlsEdward Thomson2022-06-171-3/+10
| | | | | | | | | | | | | | | | | | Enforce the RFC for other protocols; Google's questionable choices about malformed SSH protocols shouldn't impact our ability to properly parse HTTPS.
| * | url_parse: introduce our own url parsingEdward Thomson2022-06-172-84/+325
| | | | | | | | | | | | | | | Provide our own url parser, so that we can handle Google Code's "fun" URLs that have a userinfo with an `@` in it. :cry:
* | | Merge pull request #6382 from csware/fix_mem_leakEdward Thomson2022-09-191-3/+3
|\ \ \ | | | | | | | | Fix memory leak
| * | | Fix memory leakSven Strickroth2022-08-141-3/+3
| | |/ | |/| | | | | | | Signed-off-by: Sven Strickroth <email@cs-ware.de>
* | | Update src/util/rand.cEdward Thomson2022-09-191-1/+1
| | |
* | | fix compile on Windows with -DWIN32_LEAN_AND_MEANChristoph Cullmann2022-08-081-0/+4
|/ / | | | | | | ensure the needed wincrypt.h is included
* | Merge pull request #6191 from libgit2/ethomson/sha256_pocEdward Thomson2022-07-133-3/+69
|\ \ | | | | | | RFC: SHA256 proof of concept
| * | sha256: make sha256 an experimental optional featureEdward Thomson2022-06-201-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | libgit2 can be built with optional, experimental sha256 support. This allows consumers to begin testing and providing feedback for our sha256 support while we continue to develop it, and allows us to make API breaking changes while we iterate on a final sha256 implementation. The results will be `git2-experimental.dll` and installed as `git2-experimental.h` to avoid confusion with a production libgit2.
| * | meta: generated `features.h` is now `git2_features.h`Edward Thomson2022-06-203-3/+67
| |/ | | | | | | | | Linux has a /usr/include/features.h, which gets confusing; update this to `git2_features.h` and move it into the `util` directory.
* | repo: allow users running with sudo to access their repositoriesEdward Thomson2022-07-122-15/+43
| | | | | | | | | | | | | | | | In the ownership checks implemented for CVE-2022-24765, we disallowed users to access their own repositories when running with `sudo`. Examine the `SUDO_UID` environment variable and allow users running with `sudo`. This matches git's behavior.
* | fs: allow ownership match if user is in admin groupEdward Thomson2022-07-072-7/+26
| | | | | | | | | | | | Allow the user ownership to match if the file is owned by the admin group and the user is in the admin group, even if the current process is not running as administrator directly.
* | fs: refactor file ownership checksEdward Thomson2022-07-072-102/+49
| | | | | | | | | | Refactor the file ownership checks so that callers can provide discrete information about the ownership expectations to a single function.
* | fs: remove mock naming from change ownership constantsEdward Thomson2022-07-072-18/+31
|/ | | | | | The file ownership concepts can reflect the actual file ownership, they are not necessarily limited to mocking the interface. Rename them so that they can be more broadly applicable.
* cmake: only use `getloadavg` where it existsEdward Thomson2022-06-131-2/+6
|