[gnutls-devel] GnuTLS | sockets: fixed building with compilers without VLA support (!1489)

Read-only notification of GnuTLS library development activities gnutls-devel at lists.gnutls.org
Fri Nov 26 09:57:15 CET 2021




Daiki Ueno started a new discussion on lib/system/sockets.c: https://gitlab.com/gnutls/gnutls/-/merge_requests/1489#note_744605766

>  system_writev(gnutls_transport_ptr_t ptr, const giovec_t * iovec,
>  	      int iovec_cnt)
>  {
> -	WSABUF bufs[iovec_cnt];
> +	WSABUF bufs_stack[16];
> +	WSABUF * bufs;
>  	DWORD bytes_sent;
>  	int to_send_cnt = 0;
>  	size_t to_send_bytes = 0;
> +	ssize_t ret;
> +
> +	if ((size_t)iovec_cnt > sizeof(bufs_stack) / sizeof(bufs_stack[0]))
> +	{
> +		bufs = (WSABUF *) malloc (iovec_cnt * sizeof(WSABUF));

I wonder what if we just force the 16 elements maximum instead of allocating extra; in that case `system_writev` would still report the actual bytes written so the caller can repeat sending?

-- 
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/gnutls/-/merge_requests/1489#note_744605766
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/20211126/08c7fbd3/attachment.html>


More information about the Gnutls-devel mailing list