From 1129de34c72d3fcf5155f3693cfd39ecb5db5870 Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Thu, 11 May 2017 08:07:54 -0700 Subject: [PATCH] Fix stack overflow in SSHCredentials constructor (#21779) --- base/libgit2/types.jl | 2 +- test/libgit2.jl | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/base/libgit2/types.jl b/base/libgit2/types.jl index 19fdc67f7d720..89cb7e16a34ef 100644 --- a/base/libgit2/types.jl +++ b/base/libgit2/types.jl @@ -699,7 +699,7 @@ mutable struct SSHCredentials <: AbstractCredentials finalizer(c, securezero!) return c end - SSHCredentials(u::AbstractString,p::AbstractString,prompt_if_incorrect::Bool=false) = SSHCredentials(u,p,prompt_if_incorrect) + SSHCredentials(u::AbstractString,p::AbstractString,prompt_if_incorrect::Bool=false) = SSHCredentials(u,p,"","",prompt_if_incorrect) SSHCredentials(prompt_if_incorrect::Bool=false) = SSHCredentials("","","","",prompt_if_incorrect) end diff --git a/test/libgit2.jl b/test/libgit2.jl index 26e899c72bea8..bd6c4a8144f41 100644 --- a/test/libgit2.jl +++ b/test/libgit2.jl @@ -1249,6 +1249,11 @@ mktempdir() do dir @test LibGit2.checkused!(creds) @test creds.user == creds_user @test creds.pass == creds_pass + sshcreds = LibGit2.SSHCredentials(creds_user, creds_pass) + @test sshcreds.user == creds_user + @test sshcreds.pass == creds_pass + @test isempty(sshcreds.prvkey) + @test isempty(sshcreds.pubkey) end # The following tests require that we can fake a TTY so that we can provide passwords