Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: curl_lib func:Curl_pin_peer_pubkey() may cause a memory leak #26

Open
coolc4 opened this issue Dec 15, 2021 · 1 comment
Open

Bug: curl_lib func:Curl_pin_peer_pubkey() may cause a memory leak #26

coolc4 opened this issue Dec 15, 2021 · 1 comment

Comments

@coolc4
Copy link

coolc4 commented Dec 15, 2021

edrav2/eprj/curl/lib/vtls/vtls.c:

CURLcode Curl_pin_peer_pubkey(struct Curl_easy *data,
const char *pinnedpubkey,
const unsigned char *pubkey, size_t pubkeylen)
{
........

/* compute sha256sum of public key */
sha256sumdigest = malloc(CURL_SHA256_DIGEST_LENGTH);
if(!sha256sumdigest)
  return CURLE_OUT_OF_MEMORY;

//sha256sumdigest malloc ok

encode = Curl_ssl->sha256sum(pubkey, pubkeylen,
                    sha256sumdigest, CURL_SHA256_DIGEST_LENGTH);

if(encode != CURLE_OK)
  return encode;
**// here  maybe memleak**

encode = Curl_base64_encode(data, (char *)sha256sumdigest,
                            CURL_SHA256_DIGEST_LENGTH, &encoded,
                            &encodedlen);
Curl_safefree(sha256sumdigest);

if(encode)
  return encode;

.....

@coolc4
Copy link
Author

coolc4 commented Dec 15, 2021

And I fixed the bug by th patch:
curl_vtls_pubkey_memleak.txt

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

No branches or pull requests

1 participant