[gnutls-devel] GnuTLS | Sockets: implement sendmsg()-like function on Win32 (!1377)

Read-only notification of GnuTLS library development activities gnutls-devel at lists.gnutls.org
Mon Feb 15 19:57:24 CET 2021




Evgeny Grin commented on a discussion on lib/system/sockets.c: https://gitlab.com/gnutls/gnutls/-/merge_requests/1377#note_509556996

>  }
> +
> +ssize_t
> +system_writev(gnutls_transport_ptr_t ptr, const giovec_t * iovec,
> +	      int iovec_cnt)
> +{
> +	WSABUF bufs[iovec_cnt];
> +	DWORD bytes_sent;
> +	int to_send_cnt;
> +	size_t to_send_bytes = 0;
> +	bool ovrflwn = false;
> +
> +	for (to_send_cnt = 0; to_send_cnt < iovec_cnt && !ovrflwn;
> +			++to_send_cnt) {
> +		if (to_send_bytes + iovec[to_send_cnt].iov_len > SSIZE_MAX ||
> +				iovec[to_send_cnt].iov_len > SSIZE_MAX) {

As per GnuTLS guidelines, I'm trying to avoid comments in code. :)

If `iovec[to_send_cnt].iov_len` is large enough (close to 2x`SSIZE_MAX`) then sum of (something + large enough) can warp (overflow) to number less then `SSIZE_MAX`.

-- 
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/gnutls/-/merge_requests/1377#note_509556996
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/20210215/0ee7056d/attachment.html>


More information about the Gnutls-devel mailing list