[Help-gnutls] gnutls_record_send() problem

Laurent Birtz laurent.birtz at kryptiva.com
Wed Jan 23 00:44:29 CET 2008

Nikos Mavrogiannopoulos wrote:
> On Monday 21 January 2008, Laurent Birtz wrote:
>> I've encountered a weird problem with the stock code examples (anonymous
>> server and client). By itself the example works fine, but if I replace
>> the string sent ("GET / HTTP/1.0\r\n\r\n") by a zeroed buffer, then the
>> client hangs. This does not occur if I send a buffer containing bytes
>> with the value 1.
> Where does the client hang? gnutls does not parse or use the data to be sent 
> in any way, so it's quite unlikely that sending nulls hangs gnutls.
OK, I found the problem. The server calls strlen() on the buffer,
which result in 0 bytes being sent to the client, c.f.
gnutls_record_send (session, buffer, strlen (buffer)) instead of
gnutls_record_send (session, buffer, ret).

> gnutls does not parse or use the data to be sent in any way

In version 2.0.4-1, valgrind was passing me this warning when I run it on
the example. I assumed some kind of compression bug was going on in when I
used a zeroed buffer.

==1785== Conditional jump or move depends on uninitialised value(s)
==1785==    at 0x4235432: (within /usr/lib/libz.so.
==1785==    by 0x4235DCF: deflate (in /usr/lib/libz.so.
==1785==    by 0x406128B: _gnutls_compress (in /usr/lib/libgnutls.so.13.9.1)
==1785==    by 0x40541FD: _gnutls_m_plaintext2compressed (in /usr/lib/libgnutls.so.13.9.1)
==1785==    by 0x4054A13: _gnutls_encrypt (in /usr/lib/libgnutls.so.13.9.1)
==1785==    by 0x4052C5D: _gnutls_send_int (in /usr/lib/libgnutls.so.13.9.1)
==1785==    by 0x4052F0A: gnutls_record_send (in /usr/lib/libgnutls.so.13.9.1)
==1785==    by 0x8048D6B: main (ex-client1.c:73)

Laurent Birtz

More information about the Gnutls-help mailing list