[gnutls-devel] GnuTLS | gnutls_pkcs7_import may cause memory leak (#1387)

Read-only notification of GnuTLS library development activities gnutls-devel at lists.gnutls.org
Mon Jul 25 12:16:57 CEST 2022



Zoltán Fridrich created an issue: https://gitlab.com/gnutls/gnutls/-/issues/1387

Assignee: Zoltán Fridrich

Following code snipet will cause a memory leak:

```
gnutls_pkcs7_init(&pkcs7));
gnutls_pkcs7_set_crt(pkcs7, cert);
gnutls_pkcs7_import(pkcs7, &data, GNUTLS_X509_FMT_PEM));
```

1. After `gnutls_pkcs7_init()` the `pkcs7.signed_data` will contain `NULL`
2. Because `pkcs7.signed_data` is `NULL`, it will be initialized for the first time in `gnutls_pkcs7_set_crt()`
3. `gnutls_pkcs7_import()` then creates a new asn1 element and overwrites already set `pkcs7.signed_data` leaking memory in the process

More precisely, this is the point where the data are leaked https://gitlab.com/gnutls/gnutls/-/blob/master/lib/x509/pkcs7.c#L146

-- 
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/gnutls/-/issues/1387
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnutls-devel/attachments/20220725/9d27289c/attachment.html>


More information about the Gnutls-devel mailing list