Repository navigation
transport: reject unknown URL schemes before SSH fallback - #7384
Open
sb123sb123 wants to merge 1 commit into
Open
sb123sb123 wants to merge 1 commit into
sb123sb123 wants to merge 1 commit into
Conversation
Treat only non-URL colon paths as SSH remotes. Unknown URL schemes such as foo://example.com were otherwise mistaken for SCP-style SSH paths, which could terminate the process in the SSH transport or attempt an unintended network connection. Preserve the existing unsupported URL error and add a clone regression test that verifies the destination is cleaned up. Fixes libgit2#7377.
This branch has not been deployed
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.
Problem
git_clone()crashes on Windows when given an unregistered URL scheme such asfoo://example.cominstead of returning a libgit2 error. The issue reports an access violation in the SSH transport.Cause
When no registered transport matched an URL,
transport_find_fn()treated any URL containing a colon as an SCP-style SSH path. That routed unknownscheme://...inputs into the SSH transport, where behavior depended on the configured SSH provider.Fix
Only apply the SSH fallback to non-URL colon syntax. Unknown URL schemes now return the existing
unsupported URL protocolerror, while SCP-style paths continue to use SSH. The regression test also verifies thatgit_clone()removes its temporary destination.Fixes #7377
Tests
cmake -S ./work/libgit2-7377 -B ./work/libgit2-7377-msvc -G "Visual Studio 17 2022" -A x64 -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTS=ON -DUSE_SSH=exec -DUSE_HTTP=OFF -DUSE_HTTPS=OFFcmake --build ./work/libgit2-7377-msvc --config Release --target libgit2_tests --parallel 2Release/libgit2_tests.exe -sclone::nonetwork::unknown_url_schemeRelease/libgit2_tests.exe -sclone::nonetwork(19 passed)git diff --checkThe full test binary loaded 3,159 tests; two unrelated existing
diff::renamecases failed on this Windows host because their expected diff text differs in line-ending/content representation.Limitations
The reported LibGit2Sharp/libssh2 access violation was not reproducible with the installed toolchain because libssh2 is unavailable. The Windows build used the OpenSSH
execprovider and reproduced the shared misclassification as an unintended SSH/network attempt. HTTP/HTTPS transports and network-enabled tests were not exercised.AI assistance
This pull request was prepared with AI assistance for issue triage, code investigation, patch drafting, and test execution. I reviewed the resulting diff and test output.