@@ -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;
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> --- src/libimaevm.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)