[gnutls-devel] GnuTLS | gnutls_buffer_append_data: avoid use-after-free in the callers (!1399)

Read-only notification of GnuTLS library development activities gnutls-devel at lists.gnutls.org
Tue Mar 9 17:22:34 CET 2021



Merge request https://gitlab.com/gnutls/gnutls/-/merge_requests/1399 was reviewed by Anderson Sasaki

--
  
Anderson Sasaki started a new discussion on lib/ext/key_share.c: https://gitlab.com/gnutls/gnutls/-/merge_requests/1399#note_525378738

>  
>  		ret =
>  		    _gnutls_buffer_append_prefix(extdata, 16, 0);

Here you reserve room for the size of everything that is appended after the previously existing data, right?

--
  
Anderson Sasaki started a new discussion on lib/ext/key_share.c: https://gitlab.com/gnutls/gnutls/-/merge_requests/1399#note_525378745

>  		/* copy actual length */
> -		_gnutls_write_uint16(extdata->length - cur_length, lengthp);
> +		_gnutls_write_uint16(extdata->length - length_pos - 2,

Then here you calculate the size of everything that was appended and write to the reserved room (2 bytes)?

--
  
Anderson Sasaki started a new discussion on lib/ext/key_share.c: https://gitlab.com/gnutls/gnutls/-/merge_requests/1399#note_525378750

>  
> -		/* write the total length later */
> -		lengthp = &extdata->data[extdata->length];

The problem is that when things are reallocated, this `lengthp` pointer turns invalid, right?

--
  
Anderson Sasaki started a new discussion on lib/ext/pre_shared_key.c: https://gitlab.com/gnutls/gnutls/-/merge_requests/1399#note_525378759

> +		gnutls_datum_t client_hello;
> +
> +		client_hello.data = extdata->data+sizeof(mbuffer_st);

And here (and the next case) we have to get the pointers after the possible reallocation, right?


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


More information about the Gnutls-devel mailing list