add_dir_hash: fix DIR leak in case of failure
When bailing out of the function due to EVP_DigestUpdate() failing, the DIR resources allocated with opendir() were not freed. Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
This commit is contained in:
parent
4b56112c09
commit
fa0b30b15e
@ -214,6 +214,7 @@ static int add_dir_hash(const char *file, EVP_MD_CTX *ctx)
|
|||||||
DIR *dir;
|
DIR *dir;
|
||||||
unsigned long long ino, off;
|
unsigned long long ino, off;
|
||||||
unsigned int type;
|
unsigned int type;
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
dir = opendir(file);
|
dir = opendir(file);
|
||||||
if (!dir) {
|
if (!dir) {
|
||||||
@ -233,13 +234,14 @@ static int add_dir_hash(const char *file, EVP_MD_CTX *ctx)
|
|||||||
err |= EVP_DigestUpdate(ctx, &type, sizeof(type));
|
err |= EVP_DigestUpdate(ctx, &type, sizeof(type));
|
||||||
if (!err) {
|
if (!err) {
|
||||||
log_err("EVP_DigestUpdate() failed\n");
|
log_err("EVP_DigestUpdate() failed\n");
|
||||||
return 1;
|
result = 1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
|
|
||||||
return 0;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int add_link_hash(const char *path, EVP_MD_CTX *ctx)
|
static int add_link_hash(const char *path, EVP_MD_CTX *ctx)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user