Projects
Eulaceura:Factory
digest-list-tools
_service:obs_scm:fix-file-resource-leakage-and-...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:fix-file-resource-leakage-and-memory-leakage.patch of Package digest-list-tools
From dc73bf5d2146deb5831a63c8e267a3f325bb5e67 Mon Sep 17 00:00:00 2001 From: shenxiangwei <shenxiangwei1@huawei.com> Date: Tue, 16 Aug 2022 08:34:37 +0800 Subject: [PATCH] fix file resource leakage and memory leakage Signed-off-by: shenxiangwei <shenxiangwei1@huawei.com> --- generators/unknown.c | 3 ++- lib/xattr.c | 14 ++++++++++++++ parsers/rpm.c | 2 +- src/manage_digest_lists.c | 4 ++-- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/generators/unknown.c b/generators/unknown.c index ad17a23..3f8ecc4 100644 --- a/generators/unknown.c +++ b/generators/unknown.c @@ -164,6 +164,7 @@ static int add_file(int dirfd, int fd, char *path, u16 type, u16 modifiers, if (!ret) { caps_bin = malloc(caps_bin_len); if (!caps_bin) { + cap_free(c); ret = -ENOMEM; goto out; } @@ -217,7 +218,7 @@ static int add_file(int dirfd, int fd, char *path, u16 type, u16 modifiers, if (!ret) ret = write_check(fd, "\n", 1); - return ret; + goto out; } if (!tlv) { diff --git a/lib/xattr.c b/lib/xattr.c index 3bfb35c..166aa2e 100644 --- a/lib/xattr.c +++ b/lib/xattr.c @@ -129,19 +129,33 @@ int read_ima_xattr(int dirfd, char *path, u8 **buf, size_t *buf_len, ret = fgetxattr(fd, XATTR_NAME_IMA, NULL, 0); if (ret < 0) + { + close(fd); return -ENODATA; + } *buf_len = ret; if (*buf_len > 65536) + { + close(fd); return -ENOMEM; + } *buf = malloc(*buf_len); if (!*buf) + { + close(fd); return -ENOMEM; + } ret = fgetxattr(fd, XATTR_NAME_IMA, *buf, ret); if (ret < 0) + { + free(*buf); + *buf = NULL; + close(fd); return -ENODATA; + } ret = parse_ima_xattr(*buf, *buf_len, keyid, keyid_len, sig, sig_len, algo); diff --git a/parsers/rpm.c b/parsers/rpm.c index fc6122e..0f165b6 100644 --- a/parsers/rpm.c +++ b/parsers/rpm.c @@ -272,7 +272,7 @@ int parser(int fd, struct list_head *head, loff_t buf_size, void *buf, } if (ret < 0) - return ret; + goto out; } out: free(dirnames_ptr); diff --git a/src/manage_digest_lists.c b/src/manage_digest_lists.c index 1dc3a43..0eb4233 100644 --- a/src/manage_digest_lists.c +++ b/src/manage_digest_lists.c @@ -206,11 +206,11 @@ int main(int argc, char *argv[]) if (op == PARSER_OP_GEN_IMA_LIST) { ret = ima_copy_boot_aggregate(fd); if (ret < 0) - return ret; + goto out_close_fd; ret = ima_generate_entry(-1, fd, "", IMA_KEY_PATH); if (ret < 0) - return ret; + goto out_close_fd; } for (i = 0; i < COMPACT__LAST; i++) { -- 2.27.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2