[gnutls-dev] a few questions

Jon Nelson jnelson@securepipe.com
Tue Oct 30 15:55:02 2001


gnutls_record.c, in gnutls_send_int, if there is data remaining to be sent
from a previous interrupted write, you set cipher to NULL and cipher_size
to state->gnutls_internals.send_buffer.size +
state->gnutls_internals.send_buffer_prev_size  

Then, you call _gnutls_write_buffered(cd, state, cipher, cipher_size)

However, in gnutls_buffers.c, in _gnutls_write_buffered, the same test
(iptr == NULL) is performed (twice, actually):

/* 1st test */
if (state->gnutls_internals.send_buffer.size > 0 && iptr != NULL) {
		gnutls_assert();
		return GNUTLS_E_INVALID_PARAMETERS;
	}

	/* If data in the buffer exist
	 */

/* second test */
if (iptr == NULL) {
		if ( state->gnutls_internals.send_buffer.size == 0) {
			gnutls_assert();
			return GNUTLS_E_INVALID_PARAMETERS;
		} else {
			ptr = state->gnutls_internals.send_buffer.data;
			n = state->gnutls_internals.send_buffer.size;
		}
	}


Technically, the first test is superior on the off-chance that
gnutls_internals.send_buffer.size is < 0

However, here you set n (which was cipher_size) to
state->gnutls_internals.send_buffer.size;

Which is more appropriate?  

As a precaution, perhaps "n" (cipher_size) could be passed in as -1 from
gnutls_buffers.c in the case of handling a previously blocked write -- it
might help debugging in the future.

-- 
Jon Nelson                \|/ ____ \|/   Gort,
jnelson@securepipe.com    "@'/ ,. \`@"   Klaatu
C and Python Programmer   /_| \__/ |_\   barada
Motorcycle Enthusiast        \__U_/      nikto.