[gnutls-devel] GnuTLS | Fix out-of-bounds memcpy in gnutls_realloc_zero() (!1592)

Read-only notification of GnuTLS library development activities gnutls-devel at lists.gnutls.org
Wed May 18 12:22:49 CEST 2022




Zoltán Fridrich commented on a discussion on lib/nettle/init.c: https://gitlab.com/gnutls/gnutls/-/merge_requests/1592#note_950938145

>  	}
>  
> -	if (new_size == 0)
> -		goto done;
> +	if (old_size == new_size)
> +		return data;
>  
> -	if (new_size <= old_size) {
> -		size_t d = old_size - new_size;
> -		/* Don't bother reallocating */
> -		if (d < old_size / 2) {
> -			explicit_bzero((char *)data + new_size, d);
> -			return data;
> +	if (new_size < old_size) {
> +		explicit_bzero((char *)data + new_size, old_size - new_size);
> +		p = realloc(data, new_size);

looks correct

-- 
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/gnutls/-/merge_requests/1592#note_950938145
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/20220518/0478a314/attachment-0001.html>


More information about the Gnutls-devel mailing list