[gnutls-help] Regression bug between 2.x and 3.2?

Lavrentiev, Anton (NIH/NLM/NCBI) [C] lavr at ncbi.nlm.nih.gov
Mon Jun 16 16:54:01 CEST 2014


> From that description I think that this is pretty much expected. A call
> to gnutls_record_send() can be interrupted, and had to be called again
> (I believe that was the case in all gnutls versions). If that's not
> clear from the documentation please let me know what could be improved.

Here's the problem:  there was no interruption, there was a short write.
Previous version of GNUTLS tolerated that by calling the push callback
once again, and again, and again, giving up only when nothing _at all_
was written (-1 returned).  Current version bails out immediately.
This is a change in behavior, which is not backward compatible.
The code in gnutls_buffers.c has changed significantly:  it was presumably
necessary to accommodate a vector write operation (writev), and could have
resulted in the inadvertent change for the plain push.

Anyhow, the push callback is documented to be a send()-like thing.
Which means it is allowed to write fewer bytes than it was requested to,
and that does not constitute an error.  Previous GNUTLS version treated
that exactly so, by re-trying the write until unsuccessful (and advancing
with writes, most of the time).  Current implementation considers the
short write as a fault and returns EAGAIN.  Thus, the callback is
longer compatible with send():  if the callback wants GNUTLS to
keep writing it must ensure to push as many bytes as it was told to,
which means, it must be doing send()/wait()/send() sequences internally.

P.S.  I'm preparing a test case which should demonstrate the changed behavior.

Anton Lavrentiev
Contractor NIH/NLM/NCBI



More information about the Gnutls-help mailing list