15946 Commits

Author SHA1 Message Date
Edward Thomson
ca225744b9 v1.9.2: update changelog and version numbers v1.9.2 2025-12-02 21:51:10 +00:00
Patrick Steinhardt
1b07eecf91 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-12-01 23:41:20 +00:00
Edward Thomson
069c905aef 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 22:53:28 +00:00
Edward Thomson
a18f214f58 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 22:53:23 +00:00
Edward Thomson
346f28b89d 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 22:53:18 +00:00
Edward Thomson
d0723d20d7 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 22:53:13 +00:00
Edward Thomson
0618182268 str: add case insensitive suffixcmp 2025-12-01 22:53:09 +00:00
Edward Thomson
fa19ed2eff 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 22:52:56 +00:00
Edward Thomson
6f3614cb47 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 22:51:47 +00:00
Edward Thomson
e0ef2c1136 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-12-01 22:51:40 +00:00
Edward Thomson
c1a7d1219a 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-12-01 22:51:35 +00:00
Edward Thomson
47dfe7fa37 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-12-01 22:51:30 +00:00
Edward Thomson
d8b452f953 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-12-01 22:51:26 +00:00
bakersdozen123
91ebc49fb9 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-12-01 22:51:21 +00:00
Edward Thomson
0060d9cf56 Merge pull request #7084 from libgit2/ethomson/v1.9.1 v1.9.1 2025-06-06 17:26:15 +01:00
Edward Thomson
4bb0ece2a2 v1.9.1: update version numbers 2025-06-06 14:40:38 +01:00
Edward Thomson
4a4d6ee080 v1.9.1: update changelog 2025-06-06 14:40:38 +01:00
Talya Connor
455a069be7 AUTHORS: add self. 2025-06-06 13:58:55 +01:00
Talya Connor
b24b9e2782 diff: account for common prefix in max namelen. 2025-06-06 13:58:55 +01:00
Talya Connor
25bcfb33dd test: failing diff stat test. 2025-06-06 13:58:55 +01:00
Nelson Elhage
48cd7e81b7 Don't use -fsanitizer for the standalone fuzzer build. 2025-06-06 13:58:55 +01:00
Nelson Elhage
6048d2bb53 fuzzers: Fix CFLAGS
I'm seeing the current fuzzer build fail (during `cmake`) like so:

```
-- Performing Test IS_FSANITIZE_FUZZER_NO_LINK_SUPPORTED
-- Performing Test IS_FSANITIZE_FUZZER_NO_LINK_SUPPORTED - Failed
CMake Error at cmake/AddCFlagIfSupported.cmake:17 (message):
  Required flag -fsanitize=fuzzer-no-link is not supported
Call Stack (most recent call first):
  fuzzers/CMakeLists.txt:6 (add_c_flag)
```

The cmake log output contains something like so:

```
        /src/aflplusplus/libAFLDriver.a(aflpp_driver.o): in function `main':
        aflpp_driver.c:(.text+0x11b): undefined reference to `LLVMFuzzerTestOneInput'
        clang: error: linker command failed with exit code 1 (use -v to see invocation)
```

I haven't figured out exactly what's happening, but I believe that
once line 5 has added `-fsanitize=fuzzer` to `CFLAGS`, future compile-
tests **also** use it during linking. This in turn pulls in the fuzzer
`main`, which expects an `LLVMFuzzerTestOneInput` symbol, and thus
fails.

Instead, just add `-fsanitize=fuzzer-no-link` to CFLAGS (as suggested
[by the documentation][libfuzzer]), and then use `-fsanitize=fuzzer`
only for linking the fuzzer targets. At least in my environment, this
results in a working fuzzer build.

[libfuzzer]: https://llvm.org/docs/LibFuzzer.html#fuzzer-usage
2025-06-06 13:58:55 +01:00
Yuriy Chernyshov
c38a362ec6 Fix circular includes between types.h and oid.h 2025-06-06 13:58:55 +01:00
wklatka
00598169d7 Fixed memory leak in openssl fips modes 2025-06-06 13:58:55 +01:00
Dominique Fuchs
e07acfda4a docs: correct docstring info for git_remote_url
Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
2025-06-06 13:58:55 +01:00
Sven Strickroth
3b8318bdd5 tag: Refuse to use HEAD as a tagname
Sync with vanilla Git, cf. https://github.com/git/git/commit/bbd445d5efd415

Signed-off-by: Sven Strickroth <email@cs-ware.de>
2025-06-06 13:58:55 +01:00
Fabio Alessandrelli
94103d14da Fix MSVC cross compilation
Currently, the DefaultCFlags.cmake overrides the
CMAKE_STATIC_LINKER_FLAGS to suppress linker warnings about files with
no symbols defined.

This has the side effect of breaking MSVC cross compilation (where
CMAKE_STATIC_LINKER_FLAGS is used to specify the /MACHINE:ARCH flag)

This commit make sure we append to CMAKE_STATIC_LINKER_FLAGS instead of
replacing its values
2025-06-06 13:58:55 +01:00
ytnuf
0922fcc46f Revert include path regression 2025-06-06 13:58:55 +01:00
Edward Thomson
3910cde282 clar: update to latest version
Update to the latest version (in HEAD) of clar. This affords us improved
test directory creation, and the `cl_invoke` helper macro.
2025-06-06 13:58:55 +01:00
Edward Thomson
298a9ba6c0 Include common.h in version.h
Fixes #7027
2025-06-06 13:58:55 +01:00
Emily
d4a7e3c5c2 conflict tests: check core.ignorecase
Not all filesystems on Apple and Windows platforms are
case‐insensitive; this test would previously fail on a
case‐sensitive APFS volume.
2025-06-06 13:58:55 +01:00
Edward Thomson
22f0130887 filter: set a temporary sysdir in test
The filter tests mutate state, and should set a temporary sysdir to do
so.
2025-06-06 13:58:55 +01:00
Edward Thomson
ecc0a4d7c7 test: set a temporary PROGRAMDATA directory
Like we set temporary system and global configuration directories, we
need to set a programdata directory for safe test handling.
2025-06-06 13:58:55 +01:00
Edward Thomson
b9f06e5323 attr: honor ignorecase in attribute matching
`.gitattributes` is case-insensitive when `core.ignorecase=true`.
2025-06-06 13:58:55 +01:00
Carlo Bramini
8f9e095af7 cli: fix undefined alloca() on CYGWIN
I tried to build my libgit2-1.9.0 package for CYGWIN but I got an error. This message appears when compiling:

[199/671] Building C object src/cli/CMakeFiles/git2_cli.dir/opt.c.o
libgit2-1.9.0/src/cli/opt.c: In function ‘cli_opt_parse’:
libgit2-1.9.0/src/cli/opt.c:564:23: warning: implicit declaration of function ‘alloca’; did you mean ‘malloc’? [-Wimplicit-function-declaration]
  564 |         given_specs = alloca(sizeof(const cli_opt_spec *) * (args_len + 1));
      |                       ^~~~~~
      |                       malloc

and later the linker emits this error message:

[668/671] Linking C executable git2.exe
FAILED: git2.exe
/usr/x86_64-pc-cygwin/bin/ld: src/cli/CMakeFiles/git2_cli.dir/opt.c.o: in function `cli_opt_parse':
/usr/src/debug/libgit2-1.9.0-1/src/cli/opt.c:564:(.text+0xce3): undefined reference to `alloca'
collect2: error: ld returned 1 exit status

The error is fixed by adding alloca.h to included headers.
Hopefully, opt.c already allows to add alloca.h for some platforms, so I just added an additional test for the preprocessor for checking if the target is CYGWIN.
2025-06-06 13:58:55 +01:00
Edward Thomson
4c57f9e565 benchmarks: update path to baseline cli
The `fullpath` function takes the cli, but doesn't keep the cli.
2025-06-06 13:58:55 +01:00
Alexander Kanavin
3900c3b0e7 src/libgit2/CMakeLists.txt: install cmake files into configured libdir
libdir can be something else than /usr/lib, e.g. /usr/lib64 or similar.
2025-06-06 13:58:55 +01:00
peter15914
ed642bbe43 transport: сheck a pointer allocation result
GIT_ERROR_CHECK_ALLOC was added to check the return value of git__calloc().
2025-06-06 13:58:55 +01:00
Edward Thomson
e855bd57c6 docs: add update_refs as ABI breaking change
In v1.9, we failed to document that `update_refs` was a breaking change.
Add information about this change to the ABI breaking changes section.
2025-06-06 13:58:55 +01:00
Edward Thomson
93aee581e2 ci: update download-artifact version 2025-06-06 13:58:55 +01:00
Mike Frysinger
f4c3b351df alternates: allow relative paths in all repositories
Git does not limit relative paths in alternates to the first
repository, so libgit2 shouldn't either.
2025-06-06 13:58:55 +01:00
Laurence McGlashan
4fb6de4cd7 Update SelectSSH.cmake 2025-06-06 13:33:22 +01:00
Florian Pircher
2a601e0d76 include: Fix code comment termination 2025-06-06 13:32:47 +01:00
Edward Thomson
ae9971347e hash: allow unsigned int != size_t in sha256
Our bundled SHA256 implementation passes a `size_t` as an `unsigned
int`. Stop doing that.
2025-06-06 13:32:35 +01:00
Edward Thomson
338e6fb681 Merge pull request #6990 from libgit2/ethomson/ci v1.9.0 2024-12-28 12:01:25 +00:00
Edward Thomson
76fe3978ae Merge pull request #6989 from libgit2/ethomson/readme 2024-12-28 11:49:15 +00:00
Edward Thomson
e447de936d ci: only build docs on main branch pushes
Don't build docs on pushes to maint branches; those docs should only be
built _on release_. In addition, be safer about not creating an existing
branch from a tracking branch.
2024-12-28 10:59:12 +00:00
Edward Thomson
d7f3fb568e README: add v1.9 builds 2024-12-28 10:27:39 +00:00
Edward Thomson
25d87c2d89 Merge pull request #6987 from libgit2/ethomson/changelog
v1.9: final changelog updates
2024-12-28 10:24:16 +00:00
Edward Thomson
1329f1a1db v1.9: final changelog updates 2024-12-28 10:02:09 +00:00