Skip to content

Commit 3ed934e

Browse files
committed
OVAL/probes/fwupdsecattr: Fix resource mgmt problems
fwupdsecattr_probe.c:326: leaked_storage: Variable "stream_id" going out of scope leaks the storage it points to. fwupdsecattr_probe.c:238: leaked_storage: Variable "appstream_name" going out of scope leaks the storage it points to. fwupdsecattr_probe.c:217: overwrite_var: Overwriting "appstream_name" in "appstream_name = dbus_value_to_string(&value_variant)" leaks the storage that "appstream_name" points to.
1 parent 431117c commit 3ed934e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/OVAL/probes/unix/linux/fwupdsecattr_probe.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,15 @@ static int get_all_security_attributes(DBusConnection *conn, void(*callback)(cha
206206

207207
switch (arg_type) {
208208
case DBUS_TYPE_UINT32:
209-
if(strncmp(property_name, "HsiResult", strlen("HsiResult")) == 0) {
209+
if(!strncmp(property_name, "HsiResult", strlen("HsiResult"))) {
210210
_DBusBasicValue hsiresult_value;
211211
dbus_message_iter_get_basic(&value_variant, &hsiresult_value);
212212
hsi_flags = hsiresult_value.u32;
213213
}
214214
break;
215215
case DBUS_TYPE_STRING:
216216
if(!strncmp(property_name, "AppstreamId", strlen("AppstreamId"))) {
217+
free(appstream_name);
217218
appstream_name = oval_dbus_value_to_string(&value_variant);
218219
dD("Element string: %s", appstream_name);
219220
}
@@ -222,8 +223,9 @@ static int get_all_security_attributes(DBusConnection *conn, void(*callback)(cha
222223
free(property_name);
223224
} while (dbus_message_iter_next(&array_entry));
224225
callback(appstream_name, hsi_flags);
225-
}
226-
while (dbus_message_iter_next(&property_iter));
226+
free(appstream_name);
227+
appstream_name = NULL;
228+
} while (dbus_message_iter_next(&property_iter));
227229

228230
dbus_message_unref(msg); msg = NULL;
229231
ret = 0;
@@ -323,7 +325,7 @@ int fwupdsecattr_probe_main(probe_ctx *ctx, void *arg)
323325
probe_cobj_set_flag(probe_ctx_getresult(ctx), SYSCHAR_FLAG_ERROR);
324326
probe_cobj_add_msg(probe_ctx_getresult(ctx), msg);
325327
SEXP_free(msg);
326-
return 0;
328+
goto exit;
327329
}
328330

329331
int res = get_all_security_attributes(dbus_conn, hsicache_callback, NULL);
@@ -335,7 +337,7 @@ int fwupdsecattr_probe_main(probe_ctx *ctx, void *arg)
335337
probe_cobj_set_flag(probe_ctx_getresult(ctx), SYSCHAR_FLAG_ERROR);
336338
probe_cobj_add_msg(probe_ctx_getresult(ctx), msg);
337339
SEXP_free(msg);
338-
return 0;
340+
goto exit;
339341
}
340342
}
341343

0 commit comments

Comments
 (0)