[gnutls-devel] GnuTLS | Correct size check in _gnutls_buffer_pop_data() ? (#844)

Development of GNU's TLS library gnutls-devel at lists.gnutls.org
Sat Oct 12 18:50:33 CEST 2019



Tim Rühsen created an issue: https://gitlab.com/gnutls/gnutls/issues/844



Shouldn't it be `if (tdata.data == NULL || tdata.size > req_size) {` ?

```
/* returns data from a string in a constant buffer. Will
 * fail with GNUTLS_E_PARSING_ERROR, if the string has not enough data.
 */
int
_gnutls_buffer_pop_data(gnutls_buffer_st * str, void *data,
			size_t req_size)
{
	gnutls_datum_t tdata;

	_gnutls_buffer_pop_datum(str, &tdata, req_size);
	fprintf(stderr,"%zu %zu\n", tdata.size, req_size);
	if (tdata.data == NULL || tdata.size != req_size) {
		return GNUTLS_E_PARSING_ERROR;
	}

	memcpy(data, tdata.data, tdata.size);

	return 0;
}
```

-- 
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/gnutls/issues/844
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/20191012/7edf0cff/attachment.html>


More information about the Gnutls-devel mailing list