Fix segfault on Android when no HOME set#7309
Merged
Merged
Conversation
On Android with no HOME set, this function was returning early as it should, but libssh2_knownhost_init was never called, so a null pointer was being passed back to the calling function.
Member
|
Makes sense; thanks! |
1 task
netbsd-srcmastr
pushed a commit
to NetBSD/pkgsrc
that referenced
this pull request
Jul 19, 2026
v1.9.6 This release includes a few small but important bugfixes. * load_known_hosts: do not fail if homedir is invalid by @JonasVautherin in libgit2/libgit2#7056 * Fix segfault on Android when no HOME set by @501st-alpha1 in libgit2/libgit2#7309 * cmake: bring back hidden visibility for the static build by @carlosmn in libgit2/libgit2#7288 v1.9.5 This is a security release with multiple changes. * Fix for blame error handling on hunk creation failures `hunk_from_entry` can return `NULL` on error; handle that and return an error. * Fix for potential PCRE memory access: 1-byte heap-buffer-overflow WRITE in bundled PCRE 8.45 reachable via revspec `git_revparse_single` accepts revspecs of the form `:/<pattern>` (the "grep by commit message" shorthand) and forwards `<pattern>` directly to libgit2's regex backend. When libgit2 is using its builtin regular expression engine, this causes a heap buffer overflow. * Fix for CVE-2026-53586: give auth callback current host libgit2's builtin HTTP transport follows offsite redirects for the initial smart HTTP request by default. If the redirected server then returns 401 Unauthorized, libgit2 asks the application credential callback for credentials using the original remote URL, not the redirected URL. The returned credential is then attached to the next request to the redirected host as an Authorization header. * Fix for CVE-2026-53587: libgit2 version 1.9.4 and below is vulnerable to a heap out-of-bounds read in `set_data` in `src/libgit2/transports/smart_pkt.c`. When given capabilities, we check for the object-format capability; we need to ensure that the current packet buffer is large enough before actually doing the check. * Fix for CVE-2026-53585: Unbounded Memory Allocation via Delta Object Result-Size Header Potential denial of service because `git_delta_apply` reads the claimed result size (`res_sz`) from the delta object header — data entirely controlled by the sender — and immediately allocates a buffer of that size. * Fix for CVE-2026-53584: submodule: check paths for escaping A crafted repository with a submodule whose path contains traversal components (e.g. "../") can cause the library to create directories outside the repository's working tree. * Fix for CVE-2026-53583: inverted IP SubjectAltName comparison in OpenSSL backend. An inverted comparison in the OpenSSL TLS backend causes IP SubjectAltName (SAN) verification to accept certificates with mismatched IP addresses and reject certificates with correct IP addresses. This allows a network attacker with a valid CA-signed certificate containing any IP SAN to perform MITM attacks against libgit2 clients connecting to IP-literal HTTPS URLs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The fix for #6550, commit 45567be, has a bug: the
libssh2_knownhost_initcall a few lines down is skipped in the missing HOME case, but sinceerroris set to0, thehostspointer remains null, when calling functions expect it to be safe to dereference. This was causing my app to crash with a segfault.This PR moves the
libssh2_knownhost_initcall earlier to avoid passing back null pointers.Fixes #6550
(I have tested this updated fix on Android with a certificate_check callback set, but no known_hosts file or even HOME set, and it succeeds without errors.)