Skip to content

wincng: memory leak in _libssh2_dh_secret #856

@iruis

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 */

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