mirror of
https://git.code.sf.net/p/linux-ima/ima-evm-utils
synced 2025-04-28 06:33:36 +02:00
libimaevm: Properly check for error returned by EVP_DigestUpdate
The error checking in add_dir_hash was wrong. EVP_DigestUpdate returns 1 on success and 0 on error, so we cannot just accumulate it using or'ing. >From the man page: EVP_DigestInit_ex(), EVP_DigestUpdate(), EVP_DigestFinal_ex() Returns 1 for success and 0 for failure. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
This commit is contained in:
parent
81478c5667
commit
161a4a5026
@ -179,7 +179,6 @@ out:
|
||||
|
||||
static int add_dir_hash(const char *file, EVP_MD_CTX *ctx)
|
||||
{
|
||||
int err;
|
||||
struct dirent *de;
|
||||
DIR *dir;
|
||||
unsigned long long ino, off;
|
||||
@ -198,11 +197,10 @@ static int add_dir_hash(const char *file, EVP_MD_CTX *ctx)
|
||||
type = de->d_type;
|
||||
log_debug("entry: %s, ino: %llu, type: %u, off: %llu, reclen: %hu\n",
|
||||
de->d_name, ino, type, off, de->d_reclen);
|
||||
err = EVP_DigestUpdate(ctx, de->d_name, strlen(de->d_name));
|
||||
/*err |= EVP_DigestUpdate(ctx, &off, sizeof(off));*/
|
||||
err |= EVP_DigestUpdate(ctx, &ino, sizeof(ino));
|
||||
err |= EVP_DigestUpdate(ctx, &type, sizeof(type));
|
||||
if (!err) {
|
||||
if (EVP_DigestUpdate(ctx, de->d_name, strlen(de->d_name)) != 1 ||
|
||||
/* EVP_DigestUpdate(ctx, &off, sizeof(off)) != 1 || */
|
||||
EVP_DigestUpdate(ctx, &ino, sizeof(ino)) != 1||
|
||||
EVP_DigestUpdate(ctx, &type, sizeof(type)) != 1) {
|
||||
log_err("EVP_DigestUpdate() failed\n");
|
||||
output_openssl_errors();
|
||||
result = 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user