handle http union transition properly 13/3113/1
authorAndy Green <andy.green@linaro.org>
Mon, 18 Feb 2013 01:48:31 +0000 (09:48 +0800)
committerKevron Rees <kevron_m_rees@linux.intel.com>
Thu, 7 Mar 2013 21:01:36 +0000 (13:01 -0800)
commit1699e091797be6cfecb14d83b630771c32dded40
treedab89621f5ad168eb78d4f75080f2d5a662e7afe
parenteadf701a6f361832cb8147396b149e4d92406a39
handle http union transition properly

There's no proper transition to http union state until now.

It only becomes apparant there's a problem when you try to
return -1 from the HTTP callback, during the close action
it will try to close() a nonsense, nonzero fd pointer in
the uninitialized u.http union member.

This patch takes a copy of the allocated headers struct from
the u.hdr union state, transitions to u.http clearing down u
and then calls the HTTP callback with URI args pointing to
the still-in-scope ah allocation.  After the call, the copy ah
is freed.

That makes sure we are in the correct union state while still
giving the HTTP callback access to the URI without having to
copy it around.

Reported-by: Edwin can den Oetelaar <oetelaar.automatisering@gmail.com>
Signed-off-by: Andy Green <andy.green@linaro.org>
lib/handshake.c