Fix 2 memory leaks.

(Thanks to Brent Cook)

OK from tedu@
Fix 9 memory leaks.

(Thanks to Brent Cook)

With help from tedu@

OK from tedu@
Fix a memory leak and another one that occurs in the error paths.

(Thanks to Brent Cook)


OK from tedu@
Add a missing word.
correct issetugid sense as spotted by Stijn van Drongelen.
Substantially expand the conditional to reduce potential for error.
More KNF.
Remove another unused source file - I got suspicious when I found a
function that ended with:

        if (ret & 0x01)
        if (ret & V_ASN1_CONSTRUCTED)
        }
KNF.

I just spent too long chasing a bug in here and really should have done
this first. Gem of the day... is it an if test or a for loop? No, it is a
super ifloop!

if (!(flags & PKCS7_NOVERIFY)) for (k = 0; k < sk_X509_num(signers); k++) {
Remove yet another unused file... a backup copy (minus copyright and
includes) follows this commit message:
Fix file descriptor leak

(Thanks to Brent Cook)

OK from jsing@
Free "data" when it's no longer in use.

(Thanks to Brent Cook)

OK from jsing@
fix the identical leak in three different files.
reported by Brent Cook, original diff by logan
simplify and unobfuscate a variable to fix a mem leak.
original diff by logan
Avoid a NULL deref in i2d_ECPrivateKey() when an EC_KEY lacks the public key
member (which is perfectly acceptable).

From BoringSSL (Adam Langley), commit f71a27920a903c9c36bcb31e68781b17674d3fd2
KNF.
pk7_doit.c r1.20 introduced a NULL check that ensures that the signature
contents are not NULL, however this breaks detached signature processing.
Fix this by allowing the signature contents to be NULL when operating with
a detached signature.

Found the hard way by sthen@.

ok sthen@
Memory leak in error path of the day, from clang via dhill@bitrig;
ok dhill@bitrig
Memory-leak-in-error-path of the day in X509_ATTRIBUTE_set1_data().
ok logan@ beck@
Simplify various BIO_sock_* fuctions - less code, better variable names,
correct types and fewer casts.

ok deraadt@ miod@
More KNF.