- /* Get maximum possible buffer size. */
- size = gnutls_record_get_max_size(from);
- LOG(LOG_DEBUG, "read_from_write_to_tls(): suggested buffer size: %ld",
- (long int)size);
- if (size > gnutls_record_get_max_size(to)) {
- size = gnutls_record_get_max_size(to);
- }
- if (size > sizeof(buffer)) {
- size = sizeof(buffer);
- }
- LOG(LOG_DEBUG, "read_from_write_to_tls(): used buffer size: %ld",
- (long int)size);
-
- size_read = gnutls_record_recv(from, buffer, size);
- if (0 > size_read) {
- LOG(LOG_WARNING, "read_from_write_to_tls(): gnutls_record_recv(): %s",
- gnutls_strerror((int)size_read));
- return -1;
+ if (buffer_size > sizeof(buffer)) {
+ LOG(WARNING, "read_from_write_to_tls(): reduced buffer size to %ld",
+ (long int)(sizeof(buffer)));
+ buffer_size = sizeof(buffer);