krb5/krb5 — pull request #154 by greghudson (2014-06-14 15:26:20+00:00)
Title: Fix error checking in PKINIT authdata creation

In create_identifiers_from_stack: check for allocation errors from
PKCS7_ISSUER_AND_SERIAL_new and M_ASN1_INTEGER_dup. Use
PKCS7_ISSUER_AND_SERIAL_free to more concisely clean up the OpenSSL
issuer variable, and make sure that any partially processed value is
cleaned up on error. Use calloc to allocate krb5_cas so that all of
its pointers are initially nulled, so that
free_krb5_external_principal_identifier can operate on it safely in
case of error. Eliminate the retval variable as it was not used
safely. Rename the error label from "cleanup" to "oom" and separate
it from the successful return path (which has nothing to clean up).

[Coverity flagged a reverse-inull check because of the unnecessary "if (is != NULL)" check in the for loop. That was harmless and is trivially fixed by using PKCS7_ISSUER_AND_SERIAL_free, but all of these other issues were apparent from code inspection. They are all out-of-error issues so are unlikely to crop up in practice.]