Skip to content

Commit 6071073

Browse files
committed
OVAL/fileextendedattribute: Covscan fixes
fileextendedattribute_probe.c:148:63: warning: Use of memory after it is freed fileextendedattribute_probe.c:225:17: warning: Potential leak of memory pointed to by 'mutex' fileextendedattribute_probe.c:110:4: warning: Potential leak of memory pointed to by 'xattr_buf' 3 alike: fileextendedattribute_probe.c:185: missing_argument: No argument for format specifier "%u" fileextendedattribute_probe.c:185: missing_argument: No argument for format specifier "%s". fileextendedattribute_probe.c:185: invalid_type: Argument "*__errno_location()" to format specifier "%s" was expected to have type "char *" but has type "int".
1 parent 10897e4 commit 6071073

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/OVAL/probes/unix/fileextendedattribute_probe.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,13 @@ static int file_cb(const char *prefix, const char *p, const char *f, void *ptr,
107107

108108
if (xattr_count == 0) {
109109
free(st_path_with_prefix);
110+
free(xattr_buf);
110111
return 0;
111112
}
112113

113114
if (xattr_count < 0) {
114115
free(st_path_with_prefix);
115-
dD("FAIL: llistxattr(%s, %p, %zu): errno=%u, %s.", errno, strerror(errno));
116+
dD("FAIL: llistxattr(%s, %p, %zu): errno=%u, %s", st_path_with_prefix, NULL, 0, errno, strerror(errno));
116117
return 0;
117118
}
118119

@@ -127,8 +128,10 @@ static int file_cb(const char *prefix, const char *p, const char *f, void *ptr,
127128
} while (errno == ERANGE);
128129

129130
if (xattr_count < 0) {
130-
dD("FAIL: llistxattr(%s, %p, %zu): errno=%u, %s.", errno, strerror(errno));
131+
dD("FAIL: llistxattr(%s, %p, %zu): errno=%u, %s", st_path_with_prefix, xattr_buf, xattr_buflen, errno, strerror(errno));
132+
free(st_path_with_prefix);
131133
free(xattr_buf);
134+
return 0;
132135
}
133136

134137
/* update lastpath if needed */
@@ -181,7 +184,7 @@ static int file_cb(const char *prefix, const char *p, const char *f, void *ptr,
181184

182185
free(xattr_val);
183186
} else {
184-
dD("FAIL: lgetxattr(%s, %s, NULL, 0): errno=%u, %s.", errno, strerror(errno));
187+
dD("FAIL: lgetxattr(%s, %s, NULL, 0): errno=%u, %s", st_path_with_prefix, xattr_buf + i, errno, strerror(errno));
185188

186189
item = probe_item_create(OVAL_UNIX_FILEEXTENDEDATTRIBUTE, NULL, NULL);
187190
probe_item_setstatus(item, SYSCHAR_STATUS_ERROR);
@@ -222,6 +225,7 @@ void *fileextendedattribute_probe_init(void)
222225
return (void *)mutex;
223226
default:
224227
dD("Can't initialize mutex: errno=%u, %s.", errno, strerror(errno));
228+
free(mutex);
225229
}
226230
#if 0
227231
probe_setoption(PROBEOPT_VARREF_HANDLING, false, "path");

0 commit comments

Comments
 (0)