Skip to content

openssl: free the correct pointers in ecdsa_sk_openssh_priv_to_pubkey() - #2027

Closed
vszakats wants to merge 1 commit into
libssh2:masterfrom
vszakats:osslfreeptr
Closed

vszakats wants to merge 1 commit into
libssh2:masterfrom
vszakats:osslfreeptr

Conversation

@vszakats

@vszakats vszakats commented Jun 10, 2026 •

Copy link
Copy Markdown
Member

Reported by GitHub Code Quality

Follow-up to ed439a2 #698


The cast to (void *) before passing application to SSH2_FREE is incorrect. The variable application is of type const char **, and casting it to (void *) loses type information. The correct parameter should be SSH2_UNCONST(*application) to free the allocated memory pointed to by *application, similar to line 3154.

The cast to (void *) is incorrect. The variable key_handle is of type const unsigned char **, and you should be freeing the memory pointed to by *key_handle instead. Use SSH2_UNCONST(*key_handle) as done correctly on line 3159.

@vszakats vszakats changed the title openssl: free the correct pointers in ossl_ecdsa_sk_openssh_priv_to_pubkey() openssl: free the correct pointers in ecdsa_sk_openssh_priv_to_pubkey() Jun 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes incorrect frees in the OpenSSL backend’s ossl_ecdsa_sk_openssh_priv_to_pubkey() failure path by freeing the allocated buffers pointed to by *application and *key_handle (instead of mistakenly freeing the pointer variables themselves). This aligns the cleanup logic with how these outputs are allocated and with existing patterns in the file.

Changes:

  • Free *application using SSH2_UNCONST(*application) and null the output.
  • Free *key_handle using SSH2_UNCONST(*key_handle) and null the output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vszakats vszakats closed this in b8e471c Jun 10, 2026
@vszakats
vszakats deleted the osslfreeptr branch June 10, 2026 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants