[gnutls-devel] GnuTLS | Add check for memory allocation APIs to avoid NULL pointer dereference (!2006)

Read-only notification of GnuTLS library development activities gnutls-devel at lists.gnutls.org
Wed Aug 6 08:10:59 CEST 2025



Merge request https://gitlab.com/gnutls/gnutls/-/merge_requests/2006 was reviewed by Daiki Ueno

--
  
Daiki Ueno started a new discussion on tests/crl_apis.c: https://gitlab.com/gnutls/gnutls/-/merge_requests/2006#note_2671478075

 >  
 >  	char *crt_buf = gnutls_calloc(DN_MAX_LEN, sizeof(char));
 > +	if (crt_buf == NULL)

Let's just abort with `assert(crt_buf != NULL);`.

--
  
Daiki Ueno started a new discussion on tests/crl_apis.c: https://gitlab.com/gnutls/gnutls/-/merge_requests/2006#note_2671478089

 > +	if (crl_buf == NULL) {
 > +		gnutls_free(crt_buf);
 > +		exit(1);

Same here, if we exit upon failure in tests, we don't care about memory leak, so just abort without free.

--
  
Daiki Ueno started a new discussion on tests/pskself2.c: https://gitlab.com/gnutls/gnutls/-/merge_requests/2006#note_2671478096

 > +		gnutls_global_deinit();
 > +		fail("client: malloc failed\n");
 > +		return;

Let's just abort on failure: `assert(user.data != NULL);`.

--
  
Daiki Ueno started a new discussion on tests/rehandshake-switch-srp-id.c: https://gitlab.com/gnutls/gnutls/-/merge_requests/2006#note_2671478102

 > +	if (generator->data == NULL) {
 > +		fail("gnutls_malloc failed\n");
 > +		return GNUTLS_E_MEMORY_ERROR;

Same here.


-- 
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/gnutls/-/merge_requests/2006
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/20250806/571414de/attachment-0001.html>


More information about the Gnutls-devel mailing list