Fix coverity lasso_get_hmac_key() warning

lasso_get_hmac_key() did not check return value. Now check the return
code, emit a critical message and return early with cleanup.

Signed-off-by: John Dennis <jdennis@redhat.com>
License: MIT
This commit is contained in:
John Dennis 2015-06-23 10:31:24 -04:00 committed by Benjamin Dauvergne
parent b10c48058e
commit 29897506c7
1 changed files with 6 additions and 2 deletions

View File

@ -494,6 +494,7 @@ lasso_query_sign(char *query, LassoSignatureContext context)
xmlSecKeyData *key_data;
unsigned int sigret_size = 0;
LassoSignatureMethod sign_method;
lasso_error_t rc = 0;
g_return_val_if_fail(query != NULL, NULL);
g_return_val_if_fail(lasso_validate_signature_method(context.signature_method), NULL);
@ -594,8 +595,11 @@ lasso_query_sign(char *query, LassoSignatureContext context)
case LASSO_SIGNATURE_METHOD_HMAC_SHA256:
case LASSO_SIGNATURE_METHOD_HMAC_SHA384:
case LASSO_SIGNATURE_METHOD_HMAC_SHA512:
lasso_get_hmac_key(key, (void**)&hmac_key,
&hmac_key_length);
if ((rc = lasso_get_hmac_key(key, (void**)&hmac_key,
&hmac_key_length))) {
message(G_LOG_LEVEL_CRITICAL, "Failed to get hmac key (%s)", lasso_strerror(rc));
goto done;
}
g_assert(hmac_key);
md = EVP_sha1();
sigret_size = EVP_MD_size(md);