Commit Graph

14489 Commits

Author SHA1 Message Date
Carlos Martín Nieto
bbcadbbcd8 tests: move online::clone::ssh_auth_methods into the ssh test suite
We're currently running it as part of the online suite but that doesn't have any
setup for ssh so we won't find the GitHub keys we set up during the test.

It doesn't need the private key setup as we just want to make sure we see some
auth request from the server, but with the addition of hostkey checking we're
now seeing it fail when we skip these tests.
2023-01-18 21:36:10 +00:00
Carlos Martín Nieto
724ae0b201 tests: append the github.com ssh keys so we have access during tests
Currently just the one test needs it.

The ssh-rsa makes sure we're asking for the cipher we find in `known_hosts` as
that won't be the one selected by default. This will be relevant in later changes.
2023-01-18 21:34:13 +00:00
Carlos Martín Nieto
67126da8f5 ssh: verify the remote's host key against known_hosts if it exists
It turns out this has been available in libssh2 for a long time and we should
have been verifying this the whole time.
2023-01-18 21:34:07 +00:00
Edward Thomson
3b7d756ccf meta: add changelog for v1.4.4 v1.4.4 2022-07-12 13:12:57 -04:00
Edward Thomson
bb8fc663b2 meta: update version numbers to 1.4.4 2022-07-12 13:12:29 -04:00
Mark Adler
efcded852c zlib: Silence some warnings from Visual Studio C. 2022-07-07 00:23:30 -04:00
Andrzej Hunt
8a6cb7ad0f zlib: slide_hash: add MSAN annotation to suppress known read from uninitialised memory
slide_hash knowingly reads (possibly) uninitialised memory, see comment
lower down about prev[n] potentially being garbage. In this case, the
result is never used - so we don't care about MSAN complaining about
this read.

By adding the no_sanitize("memory") attribute, clients of zlib won't
see this (unnecessary) error when building and running with
MemorySanitizer. An alternative approach is for clients to build zlib
with -fsanitize-ignorelist=... where the ignorelist contains something
like 'fun:slide_hash'. But that's more work and needs to be redone
for any and all CI systems running a given project with MSAN. Adding
this annotation to zlib's sources is overall more convenient - but
also won't affect non-MSAN builds.

This specific issue was found while running git's test suite, but has
also been reported by other clients, see e.g. #518.
2022-07-07 00:23:30 -04:00
Edward Thomson
b74880b9b3 zlib: declare prototypes for new functions
The `crc32_combine_gen64` missed a prototype in our define path.
Add one.
2022-07-07 00:23:30 -04:00
Edward Thomson
f0cf45d33e zlib: updated bundled zlib to v1.2.12 2022-07-06 14:34:06 -04:00
Edward Thomson
a0c5275c79 repo: allow users running with sudo to access their repositories
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.
2022-07-06 14:34:06 -04:00
Edward Thomson
af50c16f12 repo: validate gitdir and gitlink ownership
To match git's behavior with CVE 2022-29187, validate not only the
working directory, but also the gitdir and gitlink (if it exists). This
a follow up to CVE-2022-24765 that was fixed earlier.
2022-07-06 14:34:06 -04:00
Edward Thomson
b2264f45b1 repo: allow admin owned configs by admin users
Allow users in the administrator group to use git configs that are owned
by administrators.
2022-07-06 14:34:06 -04:00
Edward Thomson
258e38b02f fs: allow ownership match if user is in admin group
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.
2022-07-06 14:34:06 -04:00
Edward Thomson
3dd9b24ef9 fs: refactor file ownership checks
Refactor the file ownership checks so that callers can provide discrete
information about the ownership expectations to a single function.
2022-07-06 14:34:06 -04:00
Edward Thomson
a98b7feba4 fs: remove mock naming from change ownership constants
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.
2022-07-06 14:34:06 -04:00
Edward Thomson
3d48195869 repo: add tests for bare repo permissions
Ensure that we test opening a bare repository with odd permissions.
2022-07-06 14:34:06 -04:00
Edward Thomson
c590801556 ci: update dockerfiles for mbedTLS new url
Update the new URL for mbedTLS.
2022-07-06 14:34:06 -04:00
Edward Thomson
d580639da8 actions: pass UID and GID to PR builds of dockerfiles 2022-07-06 14:34:06 -04:00
Edward Thomson
64a5110669 ci: updates for CI 2022-07-06 14:34:06 -04:00
Carl Dong
c39e028c19 revparse: Remove error-prone, redundant test
Originally introduced in: 776a6a8e5f

This test case has recently been fixed in bdab22384c, but that fix will only last for a year. Next year the same problem will crop up and the test will need to be re-edited.

This is not ideal as
- This test case becomes an unnecessary burden for developers
- Downstream distros or even just users who want to build older versions of libgit2 are guaranteed to have this test fail

Furthermore, this test case is entirely unnecessary, as the functionality that was originally (see 776a6a8e5f) intended to be tested is well-covered by subsequent tests which specify a date instead of a "x ago" specification.
2022-07-06 14:34:06 -04:00
Edward Thomson
7678e4e574 Merge pull request #6273 from apnadkarni/describe-crash-fix
Bug #6272 - fix crash in git_describe_commit.
2022-04-18 17:10:54 -04:00
apnadkarni
350cea37ec Makes sense.
Co-authored-by: Edward Thomson <ethomson@github.com>
2022-04-14 07:40:43 +05:30
Ashok P. Nadkarni
f016709540 Bug #6272 - fix crash in git_describe_commit.
When the passed object fails to be peeled into a commit pointer,
the cleanup code still tries to free the (uninitialized) pointer.
2022-04-13 16:09:58 +05:30
Edward Thomson
465bbf88ea Merge pull request #6270 from libgit2/ethomson/v1.4.3
v1.4.3 release
v1.4.3
2022-04-12 16:17:07 -04:00
Edward Thomson
0e5eff4d7b meta: changelog for v1.4.3 2022-04-12 15:42:08 -04:00
Edward Thomson
a63532aafd meta: update version numbers for v1.4.3 2022-04-12 15:29:28 -04:00
Edward Thomson
ff85adf0d7 Merge pull request #6269 from libgit2/ethomson/14_backports
Backports to v1.4
2022-04-12 15:29:11 -04:00
Edward Thomson
8d9842993c Update src/libgit2/diff_print.c 2022-04-12 14:18:03 -04:00
Iliyas Jorio
9d6b6c5d0a diff_delta_format_path: handle null filename
This fixes a crash in test cases
test_diff_parse__new_file_with_space_and_regenerate_patch
and
test_diff_parse__delete_file_with_space_and_regenerate_patch
2022-04-12 14:17:56 -04:00
Iliyas Jorio
8e29fa38c0 test: add test that regenerates patches with spaces in filename
This currently crashes, proposed fix in subsequent commit.
2022-04-12 14:17:48 -04:00
lhchavez
c93609120a [midx] Fix an undefined behavior (left-shift signed overflow)
There was a missing check to ensure that the `off64_t` (which is a
signed value) didn't overflow when parsing it from the midx file. This
shouldn't have huge repercusions since the parsed value is immediately
validated afterwards, but then again, there is no such thing as "benign"
undefined behavior.

This change makes all the bitwise arithmetic happen with unsigned types
and is only casted to `off64_t` until the very end.

Thanks to Taotao Gu for finding and reporting this!
2022-04-12 14:17:24 -04:00
Edward Thomson
99336fe3dd fetch: support OID refspec without dst
Support the ability to create a refspec that is a single object ID
without a destination.
2022-04-12 14:17:00 -04:00
Edward Thomson
8bc1f0d0fb Merge pull request #6267 from libgit2/ethomson/ownership_14
Validate repository directory ownership (v1.4)
2022-04-12 14:16:11 -04:00
Edward Thomson
574b5ee7bb repo: make ownership checks optional
Introduce the `GIT_OPT_SET_OWNER_VALIDATION` option, so that users can
disable repository ownership validation.
2022-04-12 09:06:01 -04:00
Edward Thomson
0fe9e5fd05 repo: honor safe.directory during ownership checks
Obey the `safe.directory` configuration variable if it is set in the
global or system configuration. (Do not try to load this from the
repository configuration - to avoid malicious repositories that then
mark themselves as safe.)
2022-04-12 09:06:01 -04:00
Edward Thomson
b6cd753bd9 repo: refactor global config loader function
Pull the global configuration loader out of the symlink check so that it
can be re-used.
2022-04-12 09:06:01 -04:00
Edward Thomson
284b2bf1f4 repo: test configuration ownership validation
Test that we prevent opening directories that are not owned by
ourselves.
2022-04-12 09:06:01 -04:00
Edward Thomson
ca27240aa0 fs_path: mock ownership checks
Provide a mock for file ownership for testability.
2022-04-12 09:06:01 -04:00
Edward Thomson
7604406729 repo: ensure that repo dir is owned by current user
Ensure that the repository directory is owned by the current user; this
prevents us from opening configuration files that may have been created
by an attacker.
2022-04-12 09:06:01 -04:00
Edward Thomson
0cc4a70db0 fs_path: refactor ownership checks into current user and system
Provide individual file ownership checks for both the current user and
the system user, as well as a combined current user and system user
check.
2022-04-12 09:06:01 -04:00
Edward Thomson
fe78c6c70c clone: update bitbucket tests 2022-04-12 09:06:01 -04:00
Edward Thomson
182d0d1ee9 changelog: update changelog with v1.4.2 information v1.4.2 2022-02-26 14:50:04 -05:00
Edward Thomson
970c3c71ce Merge pull request #6234 from libgit2/ethomson/v1.4.2
v1.4.2
2022-02-26 13:24:23 -05:00
Edward Thomson
f2c5d1b105 meta: update version numbers for v1.4.2 2022-02-26 13:00:13 -05:00
Edward Thomson
377ec9bfe7 win32: find_system_dirs does not return GIT_ENOTFOUND
Allow for no Git for Windows installation.  When there is no GfW found
in the path or registry, `git_win32__find_system_dirs` would return a
`GIT_ENOTFOUND`.  Callers were not expecting this.  Since this is no
error, we simply return `0` so that callers can move on with their
lives.
2022-02-26 12:59:16 -05:00
Carlos Martín Nieto
5d9f2aff94 test: add test for the behaviour of update_tips on error 2022-02-26 12:59:04 -05:00
Carlos Martín Nieto
43bfa124c8 remote: do store the update_tips callback error value
We use `git_error_set_after_callback_function` to determine whether
`update_tips` returned an error but do not store its return value making us
think it always returns 0.

Fix it by adding the common patter of storing it inside the `if` when calling it.
2022-02-26 12:59:00 -05:00
Edward Thomson
fdd15bcfca Merge pull request #6224 from libgit2/ethomson/v1.4.1
v1.4.1
v1.4.1
2022-02-18 09:29:55 -05:00
Edward Thomson
ab791c8376 meta: update version numbers for v1.4.1 2022-02-18 08:58:03 -05:00
Edward Thomson
2575134dac xdiff: use xdl_free not free
We've added a lovely abstraction layer in xdiff so that it can call our
allocation functions.  But it also needs to call our free functions.  We
missed some `free` calls in `xmerge.c`.  Update them to use `xdl_free`.
Without this, we will pass a pointer allocated with a custom allocator
to the system free function.  💣
2022-02-18 08:58:03 -05:00