Skip to content

wincng: memory leak in _libssh2_dh_secret #856

Closed

Description

@iruis

blob is not release in _libssh2_dh_secret

allocate

blob = malloc(public_blob_len);

crtdbg message

Detected memory leaks!
Dumping objects ->
{190} normal block at 0x000001B22B6A3210, 1544 bytes long.
 Data: <DHPB            > 44 48 50 42 00 02 00 00 CB 00 EA CD C1 ED B3 E4 
Object dump complete.

patch

--- libssh2/src/wincng.c        2023-03-19 11:55:01.368892072 +0900
+++ work/src/wincng.c   2023-03-19 11:54:23.872315351 +0900
@@ -2651,6 +2651,7 @@
         if(agreement) {
             BCryptDestroySecret(agreement);
         }
+       _libssh2_wincng_safe_free(blob, public_blob_len);
         if(status == STATUS_NOT_SUPPORTED &&
            _libssh2_wincng.hasAlgDHwithKDF == -1) {
             goto fb; /* fallback to RSA-based implementation */

Activity

  1. vszakats commented on Mar 19, 2023

    @vszakats
    Member

    Thanks! Incidently, just discovered this yesterday in #846, commit 75cdcee.

  2. added a commit that references this issue on Mar 28, 2024
    5a9944e
  3. added a commit that references this issue on Jul 14, 2024
    b6d5055
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions