Skip to content

Commit 23ddd4b

Browse files
omusjrevels
authored andcommitted
Shred payload when non-EAUTH errors occur
1 parent 40d75e2 commit 23ddd4b

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

stdlib/LibGit2/src/LibGit2.jl

+6
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,8 @@ function fetch(repo::GitRepo; remote::AbstractString="origin",
294294
catch err
295295
if isa(err, GitError) && err.code == Error.EAUTH
296296
reject(cred_payload)
297+
else
298+
Base.shred!(cred_payload)
297299
end
298300
rethrow()
299301
finally
@@ -350,6 +352,8 @@ function push(repo::GitRepo; remote::AbstractString="origin",
350352
catch err
351353
if isa(err, GitError) && err.code == Error.EAUTH
352354
reject(cred_payload)
355+
else
356+
Base.shred!(cred_payload)
353357
end
354358
rethrow()
355359
finally
@@ -584,6 +588,8 @@ function clone(repo_url::AbstractString, repo_path::AbstractString;
584588
catch err
585589
if isa(err, GitError) && err.code == Error.EAUTH
586590
reject(cred_payload)
591+
else
592+
Base.shred!(cred_payload)
587593
end
588594
rethrow()
589595
end

stdlib/LibGit2/src/types.jl

+6
Original file line numberDiff line numberDiff line change
@@ -1361,6 +1361,12 @@ end
13611361

13621362
CredentialPayload(p::CredentialPayload) = p
13631363

1364+
function Base.shred!(p::CredentialPayload)
1365+
# Note: Avoid shredding the `explicit` or `cache` fields as these are just references
1366+
# and it is not our responsibility to shred them.
1367+
p.credential !== nothing && Base.shred!(p.credential)
1368+
p.credential = nothing
1369+
end
13641370

13651371
"""
13661372
reset!(payload, [config]) -> CredentialPayload

0 commit comments

Comments
 (0)