Add support for IPv6 and for multiple CAMD addresses.
This patch adds support for connecting to CAMD over IPv6. Nice addition
is that now tsdecrypt tries each of the addresses returned when CAMD
hostname is resolved and connects to the one that works. Resolving
of the server address is done before each connect, which allows for
uninterupted migration of CAMD servers by just changing their DNS
record.
IPv6 functionality can be disabled by using -4/--ipv4 options or
if you fancy only IPv6 servers -6/--ipv6 can be used.
This time free the memory returned by crypt() only once. This way
the leak is avoided and also double free error is avoided also.
The patch fixes the following valgrind compaint:
43 bytes in 1 blocks are still reachable in loss record 1 of 1
at 0x4026844: malloc (vg_replace_malloc.c:263)
by 0x40268BE: realloc (vg_replace_malloc.c:632)
by 0x41EE411: __md5_crypt (in /lib/libcrypt-2.13.so)
by 0x41EDA56: crypt (in /lib/libcrypt-2.13.so)
by 0x805F702: newcamd_login (camd-newcamd.c:297)
by 0x9F0B10: ???
With this patch valgrind compains about leaked 43 bytes but
without the patch glibc reports double free the second time
newcamd_login() is called and crashes the program. Since the
leak is not bad (it is a static buffer allocated by glibc) just
ignore valgrind in this case.