mirror of
https://git.code.sf.net/p/linux-ima/ima-evm-utils
synced 2025-04-28 14:43:37 +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)
|
static int add_dir_hash(const char *file, EVP_MD_CTX *ctx)
|
||||||
{
|
{
|
||||||
int err;
|
|
||||||
struct dirent *de;
|
struct dirent *de;
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
unsigned long long ino, off;
|
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;
|
type = de->d_type;
|
||||||
log_debug("entry: %s, ino: %llu, type: %u, off: %llu, reclen: %hu\n",
|
log_debug("entry: %s, ino: %llu, type: %u, off: %llu, reclen: %hu\n",
|
||||||
de->d_name, ino, type, off, de->d_reclen);
|
de->d_name, ino, type, off, de->d_reclen);
|
||||||
err = EVP_DigestUpdate(ctx, de->d_name, strlen(de->d_name));
|
if (EVP_DigestUpdate(ctx, de->d_name, strlen(de->d_name)) != 1 ||
|
||||||
/*err |= EVP_DigestUpdate(ctx, &off, sizeof(off));*/
|
/* EVP_DigestUpdate(ctx, &off, sizeof(off)) != 1 || */
|
||||||
err |= EVP_DigestUpdate(ctx, &ino, sizeof(ino));
|
EVP_DigestUpdate(ctx, &ino, sizeof(ino)) != 1||
|
||||||
err |= EVP_DigestUpdate(ctx, &type, sizeof(type));
|
EVP_DigestUpdate(ctx, &type, sizeof(type)) != 1) {
|
||||||
if (!err) {
|
|
||||||
log_err("EVP_DigestUpdate() failed\n");
|
log_err("EVP_DigestUpdate() failed\n");
|
||||||
output_openssl_errors();
|
output_openssl_errors();
|
||||||
result = 1;
|
result = 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user