Skip to content

Commit 47a2662

Browse files
committed
Covscan fixes
Error: FORWARD_NULL (CWE-476): [#def17] xccdf_policy_remediate.c:383: var_compare_op: Comparing "rr" to null implies that "rr" might be null. xccdf_policy_remediate.c:384: var_deref_model: Passing null pointer "rr" to "_rule_add_info_message", which dereferences it. Error: FORWARD_NULL (CWE-476): [#def18] test_fsdev_is_local_fs.c:35: assign_zero: Assigning: "ment.mnt_fsname" = "NULL". test_fsdev_is_local_fs.c:37: var_deref_model: Passing "&ment" to "is_local_fs", which dereferences null "ment.mnt_fsname".
1 parent dbb2d8f commit 47a2662

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/OVAL/probes/fsdev.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ static int is_local_fs(struct mntent *ment)
9797
return 0;
9898
}
9999

100+
if (ment->mnt_fsname == NULL) {
101+
return 0;
102+
}
103+
100104
s = ment->mnt_fsname;
101105
/* If the fsname begins with "//", it is probably CIFS. */
102106
if (s[0] == '/' && s[1] == '/')

src/XCCDF_POLICY/xccdf_policy_remediate.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,11 @@ static inline int _xccdf_fix_decode_xml(struct xccdf_fix *fix, char **result)
380380
#if defined(unix) || defined(__unix__) || defined(__unix)
381381
static inline int _xccdf_fix_execute(struct xccdf_rule_result *rr, struct xccdf_fix *fix)
382382
{
383-
if (fix == NULL || rr == NULL || oscap_streq(xccdf_fix_get_content(fix), NULL)) {
383+
if (rr == NULL) {
384+
return 1;
385+
}
386+
387+
if (fix == NULL || oscap_streq(xccdf_fix_get_content(fix), NULL)) {
384388
_rule_add_info_message(rr, "No fix available.");
385389
return 1;
386390
}
@@ -481,7 +485,11 @@ static inline int _xccdf_fix_execute(struct xccdf_rule_result *rr, struct xccdf_
481485
#else
482486
static inline int _xccdf_fix_execute(struct xccdf_rule_result *rr, struct xccdf_fix *fix)
483487
{
484-
if (fix == NULL || rr == NULL || oscap_streq(xccdf_fix_get_content(fix), NULL)) {
488+
if (rr == NULL) {
489+
return 1;
490+
}
491+
492+
if (fix == NULL || oscap_streq(xccdf_fix_get_content(fix), NULL)) {
485493
_rule_add_info_message(rr, "No fix available.");
486494
return 1;
487495
} else {

0 commit comments

Comments
 (0)