memleaks found by valgrind
raise SIGSEGV unconditionally on sshbuf corruption

it's unsafe to continue in this case, so don't try.
fix broken sshbuf_set_max_size

a duplicate assignment to rlen messed up what we were intending to do

fix regress failure caused by bad math when doing sshbuf_set_max_size
on a buffer with no data in it
bzero sizeof(*ptr) not sizeof(ptr)

spotted by Ben Hawkes
fix loop direction while searching for tun device

Patch from Matthew Dempsky
explain logic a little better here
short-circuit sshbuf_maybe_pack when buf->off==0
check sshbuf_from return value in sshbuf_fromb

Spotted by Ben Hawkes
check for nul-termination of SOCKS4 username

Spotted by Ben Hawkes
fix exploitable u32 overflow in sshbuf_get_cstring

when len > 2^32-4 it will wrap. Add a new "string too long" error
to report excessive string lengths and add a unit test that would
have caught this.

Spotted by Ivan Fratric
zero char*ish arguments passed by pointer early

in some error paths, we were not zeroing pointer arguments that
were passed by reference. This was error prone: if a caller failed
to check the return value then they could end up using whatever
was on the heap.

This lead to one possibly-exploitable bug in ssh_rsa_verify()

Spotted by Ben Hawkes
explicitly initialise ktype to NULL

strictly not needed with last sshbuf_get_cstring change but
since we free(ktype) in the error path, it's good to be clear.
clear sigblob on realloc failure

Spotted by Matthew Dempsky
fix memory leak on sshbuf_new failure in cert_new

Spotted by Matthew Dempsky
reduce SSHBUF_SIZE_MAX from 512->128MB

512MB is a scary number since 512MB*sizeof(void*) on a 32bit platform
is an unsigned overflow. We don't need 512MB buffers anyway, so it's
much better to play safe.

Recommended by Ben Hawkes
test string length against SSHBUF_SIZE_MAX
fix missing assignment to ret

certification could fail due to a buffer error, but it would report
success due to the previous buffer put clearing ret.

Spotted by Ben Hawkes
if using a return value, initialise it to an error
potentially exploitable free(uninitialised)

initialise blob, since we free it unconditionally on the error path

Spotted by Ron Bowes
cert_new() may call cert_free() now, so move it up