Commit Graph

16068 Commits

Author SHA1 Message Date
Łukasz Langa
2b7114047e (bump CI as curl failed) 2025-12-11 19:01:19 +01:00
Łukasz Langa
81ba023838 Some versions of leaks want -exclude to not have a space 2025-12-11 18:11:50 +01:00
Łukasz Langa
ed1f2f7eb1 Exclude leaks in SSLHandshake 2025-12-11 17:05:48 +01:00
Łukasz Langa
a44b3257ba Also update nightlies 2025-12-11 12:29:56 +01:00
Łukasz Langa
c81b74fe76 Use macos-14 for experimental features, too 2025-12-11 12:28:44 +01:00
Łukasz Langa
97d17cced3 Switch to macos-14 as macos-13 runners are now retired 2025-12-11 12:28:30 +01:00
Edward Thomson
610dcaac06 Merge pull request #7153 from ambv/fix-iterator-index-case-folding-test-docker 2025-12-06 21:54:41 +00:00
Edward Thomson
ce0524670c Merge pull request #7120 from xokdvium/refspec-del
refspec: Detect DEL character in is_valid_name
2025-12-06 17:54:52 +00:00
Edward Thomson
a136eb0c8d Merge pull request #7130 from orgads/init-locals
Fix potential access to uninitialized variables
2025-12-06 17:48:28 +00:00
Edward Thomson
3c30b6fab3 Merge pull request #7138 from jar-of-salt/git-authors-docs-update
Fix Contributing Docs: Incorrect Git Authors Link
2025-12-06 17:46:10 +00:00
Edward Thomson
96eddf51f9 Merge pull request #7161 from ibrahimcetin/add-swiftgitx
Add SwiftGitX to README bindings list
2025-12-06 17:44:42 +00:00
Edward Thomson
31ab9b66c7 Merge pull request #7152 from ambv/update-fedora-docker
ci: update ci/docker/fedora to work with Rawhide 44
2025-12-06 17:38:41 +00:00
Edward Thomson
9fd0741910 Merge pull request #7154 from ShiningMassXAcc/fix-C4703
Fix C4703 uninitialized pointer variable warnings
2025-12-06 17:36:57 +00:00
Edward Thomson
6af47d3989 Merge pull request #7155 from aware70/use-cmake-install-includedir-for-install-interface
Use CMAKE_INSTALL_INCLUDEDIR for libgit2package INSTALL_INTERFACE
2025-12-06 17:28:55 +00:00
Edward Thomson
80cc5c6bd6 Merge pull request #7119 from ehuss/cert_cb-always-called
Update documentation to clarify that cert cb is always called
2025-12-06 17:25:38 +00:00
Edward Thomson
cfed471032 Merge pull request #7102 from pks-gitlab/pks-refformat-extension
Introduction of the "refFormat" extension
2025-12-06 16:58:16 +00:00
Edward Thomson
092bf79393 Merge pull request #7163 from libgit2/ethomson/ssh_exec_updates
SSH exec updates
2025-12-06 16:41:10 +00:00
Edward Thomson
7af54d0866 Merge pull request #7146 from bakersdozen123/fix/custom-ssh-heap-overflow
ssh: fix custom ssh heap buffer overflow
2025-12-06 13:24:59 +00:00
Edward Thomson
7ed8f12087 ssh_exec: use GIT_SSH_COMMAND in tests
We specify additional arguments to the ssh executable; as a result, we
specify arguments with `GIT_SSH_COMMAND`.
2025-12-01 21:44:36 +00:00
Edward Thomson
dfadbd0c8f ssh_exec: support GIT_SSH_COMMAND
Look for the `GIT_SSH_COMMAND` environment variable and prefer it to
`GIT_SSH`. The `GIT_SSH_COMMAND` will execute via the shell, which is
useful to provide additional arguments.
2025-12-01 21:44:36 +00:00
Edward Thomson
f05143b946 ssh_exec: escape remote paths properly
When sending paths to the remote server, escape them properly.
Escape them with a single quote, followed by the escaped character,
followed by another single quote. This prevents misparsing on the
remote side and potential command injection.
2025-12-01 21:44:36 +00:00
Edward Thomson
4c9134e501 str: allow escaping with prefix and suffix
Allow `git_str_puts_escaped` to take an escaping prefix and an escaping
suffix; this allows for more options, including the ability to better
support escaping executed paths.
2025-12-01 21:44:36 +00:00
Edward Thomson
adac288376 str: add case insensitive suffixcmp 2025-12-01 21:44:36 +00:00
Edward Thomson
479a1b5a92 ssh_exec: don't use sh for ssh execution
Construct the arguments for the ssh exec as an explicit array, instead
of trying to create a command-line for sh. The latter may use user input
(the remote path) so this may be vulnerable to command injection.
2025-12-01 21:44:36 +00:00
Edward Thomson
2ad709e77c process: resolve paths for win32
When using `git_process_new` on win32, resolve the path to the
application in the same way that we do on POSIX.

Search `PATH` for command to execute (unless the given executable is
fully qualified). In addition, better match Windows executable lookup
behavior itself (allowing the command to be `foo`, and looking for a
matching `foo.exe` or `foo.cmd`.)
2025-12-01 21:44:36 +00:00
İbrahim Çetin
d41e7d9b38 Add SwiftGitX to README bindings list 2025-12-01 15:03:04 +03:00
Edward Thomson
98ba974617 process: improved process execution with shell
By default, `git_process_new` will no longer try to prepare a single
string to execute with the shell. Instead, by default, arguments remain
parameterized and the command to execute is located within the `PATH`.

The shell can also still optionally be used (so that additional
arguments can be included and variables handled appropriately) but this
is done by keeping arguments parameterized for safety.

This new behavior prevents accidental misuse and potential command-line
injection.
2025-11-30 23:51:52 +00:00
Edward Thomson
4d1e950326 fs: improve executable search on Windows
Ensure that when we look for an executable on Windows that we add
executable suffixes (`.exe`, `.cmd`). Without this, we would not support
looking for (eg) `ssh`, since we actually need to identify a file named
`ssh.exe` (or `ssh.cmd`) in `PATH`.
2025-11-29 12:50:44 +00:00
Edward Thomson
0f20ba29c1 fs: improve path-in-executable location
* Do not search `PATH` for fully- or partially-qualified filenames
  (eg, `foo/bar`)
* Ensure that a file in the `PATH` is executable before returning it
2025-11-29 12:50:44 +00:00
Edward Thomson
ed39bcee40 fs: improved executable-in-path location tests
Ensure that our `find_executable` behaves as expected:

* When the executable contains a fully- or partially-qualified filename
  component (eg, `foo/bar`) that `PATH` is not searched; these paths are
  relative to the current working directory.
* An empty segment in `PATH` (on POSIX systems) is treated as the
  current directory; this is for compatibility with Bourne shells.
* When a file exists in `PATH`, it is actually executable (on POSIX)
2025-11-29 12:50:44 +00:00
aware70
40ba2260a8 Use CMAKE_INSTALL_INCLUDEDIR for libgit2package INSTALL_INTERFACE include dir 2025-10-31 16:57:09 -05:00
Nathan Baird
ecc995f566 a few more variables set to NULL 2025-10-29 09:43:38 -07:00
Nathan Baird
00db738718 net.c 2025-10-29 09:11:12 -07:00
Nathan Baird
09bdcf3d4c Fix C4703 uninitialized pointer variable warnings for VCPKG builds 2025-10-28 12:58:29 -07:00
Łukasz Langa
269427b2bb test: check the correct filesystem for case-sensitivity
It's certainly possible for the root filesystem to be case-sensitive
while /tmp is not, or vice versa. One example where this might happen
is when running Docker containers (like ci/docker/fedora) on macOS with
the repository checkout on AppleFS (not case sensitive) while the
container's /tmp is case sensitive.

This fix allows the test to pass under those circumstances as well.
2025-10-23 14:05:31 +02:00
Łukasz Langa
af72120318 Update ci/docker/fedora to work with Rawhide 44 2025-10-21 16:41:09 +02:00
bakersdozen123
4277cc75bc ssh: fix custom ssh heap buffer overflow
The `ssh_custom_free()` function calls `strlen()` on the `publickey` 
field, which stores binary data, not a null-terminated string. This 
causes a heap buffer overflow when the public key data is not 
null-terminated or contains embedded null bytes.

The `publickey` field stores binary data, as required by the underlying 
`libssh2_userauth_publickey()` function, which accepts a public key 
parameter of the type `const unsigned char*`. 

Use the stored `publickey_len` instead of `strlen()` to determine the 
correct buffer size.
2025-10-11 09:56:48 -07:00
Sam Altier
e39578a2c5 authors: add self to authors 2025-09-24 14:51:21 -04:00
Sam Altier
7684a617bf docs: update link to git.git-authors 2025-09-24 14:50:24 -04:00
Orgad Shaneh
d6486af3e9 Fix potential access to uninitialized variables
opt_usage.c:214:59: warning: 'required' may be used uninitialized [-Wmaybe-uninitialized]
  214 |                     ((spec->usage & CLI_OPT_USAGE_CHOICE) && required));
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~

diff_driver.c:343:17: warning: 'drv' may be used uninitialized [-Wmaybe-uninitialized]
  343 |         if (drv && drv != *out)
      |             ~~~~^~~~~~~~~~~~~~
2025-09-17 10:24:55 +03:00
Sergei Zimmerman
aaef091960 refspec: Detect DEL character in is_valid_name
Prior to this patch the code correctly barfed on
control characters with values lower than \040 (space),
but failed to account for DEL.

This patch fixes the behavior to be consistent with git [1]:

> They cannot have ASCII control characters (i.e. bytes whose values are
> lower than \040, or \177 DEL)

[1]: https://git-scm.com/docs/git-check-ref-format#_description
2025-08-13 12:13:50 +00:00
Eric Huss
b4ad6ffae6 Update documentation to clarify that cert cb is always called
This removes the phrase "if cert verification fails" because the
certificate callback is *always* called whether it fails or not. This
was changed in
17491f6e56,
but presumably this piece of documentation was not updated.
2025-08-12 10:12:59 -07:00
Patrick Steinhardt
58d9363f02 Merge pull request #7091 from emmanuel-ferdman/main
Update `racy.c` reference
2025-08-11 11:13:31 +02:00
Patrick Steinhardt
72e29b9b00 refdb: initialize on-disk data structures via the backend
The initialization of the on-disk state of refdbs is currently not
handled by the actual refdb backend, but it's implemented ad-hoc where
needed. This is problematic once we have multiple different refdbs as
the filesystem structure is of course not the same.

Introduce a new callback function `git_refdb_backend::init()`. If set,
this callback can be invoked via `git_refdb_init()` to initialize the
on-disk state of a refdb. Like this, each backend can decide for itself
how exactly to do this.

Note that the initialization of the refdb is a bit intricate. A
repository is only recognized as such when it has a "HEAD" file as well
as a "refs/" directory. Consequently, regardless of which refdb format
we use, those files must always be present. This also proves to be
problematic for us, as we cannot access the repository and thus don't
have access to the refdb if those files didn't exist.

To work around the issue we thus handle the creation of those files
outside of the refdb-specific logic. We actually use the same strategy
as Git does, and write the invalid reference "ref: refs/heads/.invalid"
into "HEAD". This looks almost like a ref, but the name of that ref
is not valid and should thus trip up Git clients that try to read that
ref in a repository that really uses a different format.

So while that invalid "HEAD" reference will of course get rewritten by
the "files" backend, other backends should just retain it as-is.
2025-08-04 16:34:02 +02:00
Patrick Steinhardt
f3a4619bbc tests: refactor test to not circumvent the refdb when writing HEAD
In our tests for "onbranch" config conditionals we set HEAD to point to
various different branches via `git_repository_create_head()`. This
function circumvents the refdb though and directly writes to the "HEAD"
file. While this works now, it will create problems once we have
multiple refdb backends.

Furthermore, the function is about to go away in the next commit. So
let's prepare for that and use `git_reference_symbolic_create()`
instead.
2025-08-04 16:34:02 +02:00
Patrick Steinhardt
b1ac78ecb9 repository: allow initialization with a specific refdb type
While we only support initializing repositories with the "files"
reference backend right now, we are in the process of implementing a
second backend with the "reftable" format. And while we already have the
infrastructure to decide which format a repository should use when we
open it, we do not have infrastructure yet to create new repositories
with a different reference format.

Introduce a new field `git_repository_init_options::refdb_type`. If
unset, we'll default to the "files" backend. Otherwise though, if set to
a valid `git_refdb_t`, we will use that new format to initialize the
repostiory.

Note that for now the only thing we do is to write the "refStorage"
extension accordingly. What we explicitly don't yet do is to also handle
the backend-specific logic to initialize the refdb on disk. This will be
implemented in subsequent commits.
2025-08-04 16:34:02 +02:00
Patrick Steinhardt
806a0062fd repository: wire up refStorage extension
To support multiple different reference backend implementations,
Git introduced a "refStorage" extension that stores the reference
storage format a Git client should try to use.

Wire up the logic to read this new extension when we open a repository
from disk. For now, only the "files" backend is supported by us. When
trying to open a repository that has a refstorage format that we don't
understand we now error out.

There are two functions that create a new repository that doesn't really
have references. While those are mostly non-functional when it comes to
references, we do expect that you can access the refdb, even if it's not
yielding any refs. For now we mark those to use the "files" backend, so
that the status quo is retained. Eventually though it might not be the
worst idea to introduce an explicit "in-memory" reference database. But
that is outside the scope of this patch series.
2025-08-04 16:34:02 +02:00
Patrick Steinhardt
38382ce3bc repository: only consider repo-level config to read repo format
When we read the repository format information we do so by using the
full configuration of that repository. This configuration not only
includes the repository-level configuration though, but it also includes
the global- and system-level configuration. These configurations should
in practice never contain information about which format a specific
repository uses.

Despite this obvious conceptual error there's also a more subtle issue:
reading the full configuration may require us to evaluate conditional
includes. Those conditional includes may themselves require that the
repository format is already populated though. This is for example the
case with the "onbranch" condition: we need to populate the refdb to
evaluate that condition, but to populate the refdb we need to first know
about the repository format.

Fix this by using the repository-level configuration, only, to determine
the repository's format.
2025-08-04 16:34:02 +02:00
Patrick Steinhardt
9d5f1bacc2 Merge pull request #7114 from pks-gitlab/pks-msvc-different-enum-warnings
cmake: disable warnings for operands with different enum types
2025-08-04 16:30:00 +02:00
Patrick Steinhardt
5d78d634f2 cmake: disable warnings for operands with different enum types
With a recent upgrade to a newer version of MSVC we now get a bunch of
warnings when two operands use different enum types. While sensible in
theory, in practice we have a couple of non-public enums that extend
public enums, like for example with `GIT_SUBMODULE_STATUS`.

Let's for now disable this warning to unblock our builds. The
alternative would be to add casts all over the place, but that feels
rather cumbersome.
2025-08-01 08:48:59 +02:00