Statically link cfupgrade to libcompat.

(cherry picked from commit 53e0afea0f13187811b2e92c60f2d67c3dd2b71f)
Valgrind and generic cleanups.

Started with changing some malloc()s to calloc()s to keep valgrind happy
and avoid uninitialised bytes in crypto-code, and continued with a
couple of log message refining and source cleanup.

(cherry picked from commit 3f64b67c2583f43c3c6940983ec1ac497c699d40)
cf-serverd: classic protocol authentication messages etc sanitisation.

(cherry picked from commit 5bdc99490c3f112c108ce2dca2db763c00e2bf15)
Lots of cleanups, check all values, got rid of mallocs, added better messages.

(cherry picked from commit f5c0d8b9ecf0c1b4b7e2c08f38ecc90e53310b08)
Fix 16_cf-serverd lan_open.srv tests to not connect over local loopback.

(cherry picked from commit 940c37eec3e5783b6f3688160a6a2ca9988a316a)
Do not send or receive negative numbers, might catch potential stack corruption or bad code.

(cherry picked from commit 8a36e7abece5784cdfb5f4ee5db5b02a8468f504)
A bit more logging/indentation stuff.

(cherry picked from commit 5b5b91b494674222c2886e73b71e1a06f51c2683)
Check header consistency more thoroughly.

(cherry picked from commit 3bde01b9827581d6827a44e384d880bdaae5307a)
Do not cleanup global allocations if threads are still active.

(cherry picked from commit 8e7bb326ec717c6c5da050aac41b3f646574e069)
Remove uninitialized buffers as source of entropy.

(cherry picked from commit 570724e752cf131132bb88e65a031f700b0ac424)
Small cleanups of the PRNG seeding code.

(cherry picked from commit 9e89ab0a22ff8d2b6187f04863eef64df52a6cfd)
Add a LOUD warning if entropy is not enough

Should never happen since RAND_poll() is supposed to get as much entropy
as needed from the OS-specific pool.

(cherry picked from commit 7fbdafdbaad050be0e6a1980b4e36d243a814d39)
Message was inaccurate.

(cherry picked from commit 529439fb92bf29a4a7c1b06538d3fa4ddbab5885)
Homogenous capitalisation.

(cherry picked from commit e4c2cea1c81b90e013ae874ba2f714eed2e729a9)
Free cleanup.

(cherry picked from commit d279e79b12411ab0bf87ec54cf9c52a772d4a303)
lowercase

(cherry picked from commit ebb463ba1a277ae4c9ec3770b3a21398c5db3a54)
Unchecked malloc should be xmalloc.

(cherry picked from commit 617b00bf769d49135a0f8629eac6c0a8040fb614)
Log in verbose which connection threads had to abort because of shutdown.

(cherry picked from commit 0e688048b04b962287a48ffa0fb43ce0a6fdfd7c)
Fix Windows compilation in debug mode.

(cherry picked from commit 4c4243a6cd960cd8e753dbab44397fd75b4819ba)
Use %jd and %ju instead of PRIdMAX and PRIuMAX.

The problem is that on Windows PRI[du]MAX expands to a
Windows-specific printf flag, but we are using printf wrappers, which
do not understand that flag. The 'j' flag on the other hand, is not
supported by Windows, but *is* supported by our wrapper, so it's safe
to use.

One notable exception from in the commit is a scanf which uses
PRIdMAX. scanf is not covered by our wrappers at the moment, and has
no replacement, so we need to leave that as it is. sprintf is not
covered either, but can (and should) be replaced with snprintf.

(cherry picked from commit e3c783495923f6829b77f7e43fe7e41385f1e6c2)