Skip to content

CertificateSsh constructor looks wrong #1383

Closed
@rmunn

Description

@rmunn

While reading through the LibGit2Sharp code, I noticed something that looks wrong to me. Here's the code as it is currently (lines 48-55 of CertificateSsh.cs):

            HashMD5 = new byte[16];
            fixed (byte* p = &HashMD5[0])
            {
                for (var i = 0; i < HashMD5.Length; i++)
                {
                    HashMD5[i] = p[i];
                }
            }

That looks like it's intended to copy the MD5 hash from the git_certificate_ssh struct passed in as the cert parameter. But what it's actually doing is to allocate a new 16-byte array, and copy it onto itself, basically performing a no-op.

I think that fixed (byte* p = &HashMD5[0]) should be changed to fixed (byte* p = &cert->HashMD5[0]). And likewise with the next fixed block: fixed (byte* p = &HashSHA1[0]) should be changed to fixed (byte* p = &cert->HashSHA1[0]).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions