Fix several bounds checks in ssl_add_clienthello_tlsext() and
ssl_add_serverhello_tlsext(), and convert all of them to the same idiom, for
easier review.

Math is hard, let's go webshopping.

Help and ok guenther@
Bring UTF8_{getc,putc} up-to-date: it's been a decade since 5- and 6-byte
encodings and encoding of surrogate pair code points were banned.  Add
checks for those, both to those functions and to the code decoding the
BMP and UNIV encodings.

ok miod@
KSSL is dead... nuke KSSL_DEBUG from orbit.

ok beck@ miod@
No uses of UTF8_{getc,putc}() in ports, so remove them from the public header.

ok miod@
More KNF.
KNF.
mark BIO_snprintf as deprecated, so warnings will be generated for it's
use. ok miod@ tedu@
Hello? Yes, you're speaking with OPENSSL_SYS_UNIX.

ok beck@ miod@
Stop including kssl_lcl.h and nuke it from orbit - it is a no-op now.

ok beck@ miod@
Stop pulling pqueue.h into ssl_locl.h since only a small part of libssl
actually needs it. Instead, just include it in the files where it is
actually necessary.

Also remove standard includes from pqueue.h so that they are not available
as a side effect. Just add the two includes that are needed to pqueue.c.

ok miod@
There are two actual uses of e_os2.h in libssl - an OPENSSL_GLOBAL (an
empty define) and an OPENSSL_EXTERN (which is defined as, well... extern).
The use of OPENSSL_EXTERN is already inconsistent since the lines above
and below just use plain old "extern". Expand the two uses of these macros
and stop including e_os2.h in libssl.

ok miod@
Expand the OPENSSL_{GLOBAL,EXPORT,IMPORT,EXTERN} macros - this rids the
libssl tree from all uses of these defines.

ok miod@
Add explicit #include lines for stdio.h, stdlib.h and string.h; these files
used to be pulled via <openssl/pqueue.h> which got removed, and it turns out
that there is code in the wild which currently relies upon these headers to
be brought in scope by including <openssl/dtls1.h>.

Although such code needs to be fixed to not rely upon any system header being
automagically included by including ssl headers, our goal is not to break
code for the sake of it (ok, maybe from time to time).

Hopefully, this commit can be reverted in a not-so-distant future.
if (x) free(x) -> free(x); semantic patch generated with coccinelle, carefully
eyeballed before applying. Contributed by Cyril Roelandt on tech@
Convert OPENSSL_malloc stuff back to intrinsics, a few were missed
as new stuff was brought in.
ok miod@
Mark the malloc wrapper functions as deprecated so warnings will
happen on their use.
ok miod@
don't deprecate until at least the base src tree is clean.
Move include to the top and nuke pointless comments.
Calling signal once to ignore SIGPIPE is sufficient - we do not need to do
this again in each app.

ok miod@
Replace (sometimes conditional) use of alloca with malloc, and clearing
through volatile pointers with explicit_bzero().

ok beck@ jsing@