Skip to content

Commit 8dee6cd

Browse files
StefanKarpinskistaticfloat
authored andcommitted
libgit2: fix for broken SSH host callback (#39364)
(cherry picked from commit dbaca8b)
1 parent 0ec1ea8 commit 8dee6cd

File tree

6 files changed

+11
-9
lines changed

6 files changed

+11
-9
lines changed

deps/Versions.make

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ CURL_JLL_NAME := LibCURL
3333
LAPACK_VER := 3.9.0
3434

3535
# LibGit2
36-
LIBGIT2_JLL_VER := 1.2.1+0
36+
LIBGIT2_JLL_VER := 1.2.2+0
3737
LIBGIT2_JLL_NAME := LibGit2
3838

3939
# LibSSH2
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
693080c66702c9ff106b0935f01d1f96
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
f21d5846b443188a0c604255dce77603ea861db8d4c6fc55cebd5db6da07e94ae40f0a165221c95e13db9df8777fddb05f55c865f554f45e56cd442332a95336

deps/patches/libgit2-hostkey.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ index e8cd2d180..54293cd31 100644
1818

1919
/**
2020
diff --git a/src/transports/ssh.c b/src/transports/ssh.c
21-
index f4ed05bb1..049697796 100644
21+
index f4ed05bb1..ec6366a5f 100644
2222
--- a/src/transports/ssh.c
2323
+++ b/src/transports/ssh.c
2424
@@ -523,6 +523,7 @@ static int _git_ssh_setup_conn(
@@ -47,7 +47,7 @@ index f4ed05bb1..049697796 100644
4747
cert_ptr = &cert;
4848

4949
- error = t->owner->certificate_check_cb((git_cert *) cert_ptr, 0, urldata.host, t->owner->message_cb_payload);
50-
+ if (git_net_url_is_default_port(&urldata)) {
50+
+ if (atoi(urldata.port) == SSH_DEFAULT_PORT) {
5151
+ host_and_port = urldata.host;
5252
+ } else {
5353
+ size_t n = strlen(urldata.host) + strlen(urldata.port) + 2;

stdlib/LibGit2/src/callbacks.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,14 +440,15 @@ end
440440
function ssh_knownhost_check(
441441
files :: AbstractVector{<:AbstractString},
442442
host :: AbstractString,
443-
key :: String,
443+
key :: Vector{UInt8},
444444
)
445445
if (m = match(r"^(.+):(\d+)$", host)) !== nothing
446446
host = m.captures[1]
447447
port = parse(Int, m.captures[2])
448448
else
449449
port = 22 # default SSH port
450450
end
451+
len = length(key)
451452
mask = Consts.LIBSSH2_KNOWNHOST_TYPE_PLAIN |
452453
Consts.LIBSSH2_KNOWNHOST_KEYENC_RAW
453454
session = @ccall "libssh2".libssh2_session_init_ex(
@@ -471,13 +472,12 @@ function ssh_knownhost_check(
471472
@ccall "libssh2".libssh2_knownhost_free(hosts::Ptr{Cvoid})::Cvoid
472473
continue
473474
end
474-
size = ncodeunits(key)
475475
check = @ccall "libssh2".libssh2_knownhost_checkp(
476476
hosts :: Ptr{Cvoid},
477477
host :: Cstring,
478478
port :: Cint,
479479
key :: Ptr{UInt8},
480-
size :: Csize_t,
480+
len :: Csize_t,
481481
mask :: Cint,
482482
C_NULL :: Ptr{Ptr{KnownHost}},
483483
) :: Cint

stdlib/LibGit2/test/libgit2.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2400,11 +2400,11 @@ mktempdir() do dir
24002400
CHECK_FAILURE = LibGit2.Consts.LIBSSH2_KNOWNHOST_CHECK_FAILURE
24012401

24022402
# randomly generated hashes matching no hosts
2403-
random_key = "\0\0\0\assh-rsa\0\0\0\x01#\0\0\0\x81\0¿\x95\xbe9\xfc9g\n:\xcf&\x06YA\xb5`\x97\xc13A\xbf;T+C\xc9Ut J>\xc5ҍ\xc4_S\x8a \xc1S\xeb\x15FH\xd2a\x04.D\xeeb\xac\x8f\xdb\xcc\xef\xc4l G\x9bR\xafp\x17s<=\x12\xab\x04ڳif\\A\x9ba0\xde%\xdei\x04\xc3\r\xb3\x81w\x88\xec\xc0f\x15A;AÝ\xc0r\xa1\u5fe\xd3\xf6)8\x8e\xa3\xcbc\xee\xdd\$\x04\x0f\xc1\xb4\x1f\xcc\xecK\xe0\x99"
2403+
random_key = "\0\0\0\assh-rsa\0\0\0\x01#\0\0\0\x81\0¿\x95\xbe9\xfc9g\n:\xcf&\x06YA\xb5`\x97\xc13A\xbf;T+C\xc9Ut J>\xc5ҍ\xc4_S\x8a \xc1S\xeb\x15FH\xd2a\x04.D\xeeb\xac\x8f\xdb\xcc\xef\xc4l G\x9bR\xafp\x17s<=\x12\xab\x04ڳif\\A\x9ba0\xde%\xdei\x04\xc3\r\xb3\x81w\x88\xec\xc0f\x15A;AÝ\xc0r\xa1\u5fe\xd3\xf6)8\x8e\xa3\xcbc\xee\xdd\$\x04\x0f\xc1\xb4\x1f\xcc\xecK\xe0\x99" |> codeunits |> collect
24042404
# hashes of the unique github.com fingerprint
2405-
github_key = "\0\0\0\assh-rsa\0\0\0\x01#\0\0\x01\x01\0\xab`;\x85\x11\xa6vy\xbd\xb5@\xdb;\xd2\x03K\0J\xe96\xd0k\xe3\xd7`\xf0\x8f˪\xdbN\xb4\xedóǑ\xc7\n\xae\x9at\xc9Xi\xe4wD!«\xea\x92\xe5T0_8\xb5\xfdAK2\b\xe5t\xc37\xe3 \x93e\x18F,vRɋ1\xe1n}\xa6R;\xd2\0t*dD\xd8?\xcd^\x172\xd06sǷ\x81\x15UH{U\xf0\xc4IO8)\xec\xe6\x0f\x94%Z\x95˚\xf57\xd7\xfc\x8c\x7f\xe4\x9e\xf3\x18GN\xf2\x92\t\x92\x05\"e\xb0\xa0n\xa6mJ\x16\x7f\xd9\xf3\xa4\x8a\x1aJ0~\xc1\xea\xaaQI\xa9i\xa6\xac]V\xa5\xefb~Q}\x81\xfbdO[t\\OG\x8e\xcd\b*\x94\x92\xf7D\xaa\xd3&\xf7l\x8cM\xc9\x10\vƫyF\x1d&W\xcbo\x06\xde\xc9.kd\xa6V/\xf0\xe3 \x84\xea\x06\xce\x0e\xa9\xd3ZX;\xfb\0\xbaӌ\x9d\x19p<T\x98\x92\xe5\xaaxܕ\xe2PQ@i"
2405+
github_key = "\0\0\0\assh-rsa\0\0\0\x01#\0\0\x01\x01\0\xab`;\x85\x11\xa6vy\xbd\xb5@\xdb;\xd2\x03K\0J\xe96\xd0k\xe3\xd7`\xf0\x8f˪\xdbN\xb4\xedóǑ\xc7\n\xae\x9at\xc9Xi\xe4wD!«\xea\x92\xe5T0_8\xb5\xfdAK2\b\xe5t\xc37\xe3 \x93e\x18F,vRɋ1\xe1n}\xa6R;\xd2\0t*dD\xd8?\xcd^\x172\xd06sǷ\x81\x15UH{U\xf0\xc4IO8)\xec\xe6\x0f\x94%Z\x95˚\xf57\xd7\xfc\x8c\x7f\xe4\x9e\xf3\x18GN\xf2\x92\t\x92\x05\"e\xb0\xa0n\xa6mJ\x16\x7f\xd9\xf3\xa4\x8a\x1aJ0~\xc1\xea\xaaQI\xa9i\xa6\xac]V\xa5\xefb~Q}\x81\xfbdO[t\\OG\x8e\xcd\b*\x94\x92\xf7D\xaa\xd3&\xf7l\x8cM\xc9\x10\vƫyF\x1d&W\xcbo\x06\xde\xc9.kd\xa6V/\xf0\xe3 \x84\xea\x06\xce\x0e\xa9\xd3ZX;\xfb\0\xbaӌ\x9d\x19p<T\x98\x92\xe5\xaaxܕ\xe2PQ@i" |> codeunits |> collect
24062406
# hashes of the middle github.com fingerprint
2407-
gitlab_key = "\0\0\0\vssh-ed25519\0\0\0 \a\xee\br\x95N:\xae\xc6\xfbz\bέtn\x12.\x9dA\xb6\x7f\xe79\xe1\xc7\x13\x95\x0e\xcd\x17_"
2407+
gitlab_key = "\0\0\0\vssh-ed25519\0\0\0 \a\xee\br\x95N:\xae\xc6\xfbz\bέtn\x12.\x9dA\xb6\x7f\xe79\xe1\xc7\x13\x95\x0e\xcd\x17_" |> codeunits |> collect
24082408

24092409
# various known hosts files
24102410
no_file = tempname()

0 commit comments

Comments
 (0)