fix ssl reject path for freeing header allocation 75/3075/1
authorAndy Green <andy.green@linaro.org>
Mon, 11 Feb 2013 13:43:41 +0000 (21:43 +0800)
committerKevron Rees <kevron_m_rees@linux.intel.com>
Thu, 7 Mar 2013 21:01:34 +0000 (13:01 -0800)
commit67e532ff74e0daa1a21fba0dc2fdd5c309b649e8
treeaa647438f5a58667ba9b2b82a5eec47639e75988
parent989f1c461f46783a3208e35612bebe9ce22892d2
fix ssl reject path for freeing header allocation

If the SSL connection failed before the headers came, we were not
dealing with deallocating the header malloc.  This takes care of it.

Using CyaSSL, we are then valgrind-clean for ssl client and server.

With OpenSSL, there is 88 bytes lost at init that never changes or
gets recovered.  AFAIK there's nothing to do about that.

OpenSSL also blows these during operation

==1059== Conditional jump or move depends on uninitialised value(s)
==1059==    at 0x4A0B131: bcmp (mc_replace_strmem.c:935)
==1059==    by 0x3014CDDBA8: ??? (in /usr/lib64/libcrypto.so.1.0.1c)
==1059==    by 0x3015430852: tls1_enc (in /usr/lib64/libssl.so.1.0.1c)
==1059==    by 0x3015428CEC: ssl3_read_bytes (in /usr/lib64/libssl.so.1.0.1c)
==1059==    by 0x30154264C5: ??? (in /usr/lib64/libssl.so.1.0.1c)
==1059==    by 0x4C3C596: lws_server_socket_service (server.c:153)
==1059==    by 0x4C32C1E: libwebsocket_service_fd (libwebsockets.c:927)
==1059==    by 0x4C33270: libwebsocket_service (libwebsockets.c:1225)
==1059==    by 0x401C84: main (in /usr/bin/libwebsockets-test-server)

However googling around

https://bugs.launchpad.net/ubuntu/+source/openssl/+bug/60021
http://www.openssl.org/support/faq.html#PROG13
(also the next FAQ down)

it seems OpenSSL have a relaxed attitude to this and it's expected.
It's interesting CyaSSL works fine but doesn't have that problem...

Signed-off-by: Andy Green <andy.green@linaro.org>
lib/client-handshake.c
lib/parsers.c
lib/private-libwebsockets.h
lib/server.c