diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2017-09-20 15:21:16 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2018-02-19 15:29:34 +0100 |
commit | 31956954a36973a56ddadbb6cae7d0cba7702ea5 (patch) | |
tree | 0edd3d205dab151bfce17eec1156d6603f7656cf /lib/str.c | |
parent | 732707b1faa412eef6081899e9a58a95e4c19f51 (diff) | |
download | gnutls-31956954a36973a56ddadbb6cae7d0cba7702ea5.tar.gz |
str: allow creating a read-only buffer
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Diffstat (limited to 'lib/str.c')
-rw-r--r-- | lib/str.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -123,6 +123,9 @@ gnutls_buffer_append_data(gnutls_buffer_t dest, const void *data, size_t const tot_len = data_size + dest->length; size_t const unused = MEMSUB(dest->data, dest->allocd); + if (unlikely(dest->data != NULL && dest->allocd == NULL)) + return gnutls_assert_val(GNUTLS_E_INVALID_REQUEST); + if (data_size == 0) return 0; @@ -160,6 +163,9 @@ gnutls_buffer_append_data(gnutls_buffer_t dest, const void *data, int _gnutls_buffer_resize(gnutls_buffer_st * dest, size_t new_size) { + if (unlikely(dest->data != NULL && dest->allocd == NULL)) + return gnutls_assert_val(GNUTLS_E_INVALID_REQUEST); + if (dest->max_length >= new_size) { size_t unused = MEMSUB(dest->data, dest->allocd); if (dest->max_length - unused <= new_size) { @@ -209,7 +215,6 @@ void _gnutls_buffer_pop_datum(gnutls_buffer_st * str, gnutls_datum_t * data, size_t req_size) { - if (str->length == 0) { data->data = NULL; data->size = 0; |