[gnutls-dev] a few questions

Nikos Mavroyanopoulos nmav@hellug.gr
Tue Oct 30 20:39:01 2001


On Tue, 30 Oct 2001 09:00:28 -0600 Jon Nelson <jnelson@securepipe.com> wrote:

> 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  
> /* 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
Yes the second test had no real effect. I've removed that in the
cvs. Negative values, are not valid (since the types used are unsigned).

> 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.
These functions are a bit complex... I've done some cleanups in the cvs, but
there is more to be done.

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

-- 
Nikos Mavroyanopoulos
mailto:nmav@hellug.gr