Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix coverity 1.3.8 #2007

Merged
merged 3 commits into from
Jul 21, 2023
Merged

Fix coverity 1.3.8 #2007

merged 3 commits into from
Jul 21, 2023

Conversation

evgenyz
Copy link
Contributor

@evgenyz evgenyz commented Jul 20, 2023

This PR fixes next covscan issues:

(Commit 1)

  1. Defect type: COMPILER_WARNING
    /src/OVAL/probes/unix/linux/systemdshared.h:147:12: warning[-Wunused-function]: 'get_all_systemd_units' defined but not used

  2. Defect type: COMPILER_WARNING
    /src/OVAL/probes/unix/linux/systemdshared.h:73:14: warning[-Wunused-function]: 'get_path_by_unit' defined but not used

(Commit 2)

  1. Defect type: RESOURCE_LEAK
    /src/OVAL/probes/unix/linux/fwupdsecattr_probe.c:326: leaked_storage: Variable "stream_id" going out of scope leaks the storage it points to.

  2. Defect type: RESOURCE_LEAK
    /src/OVAL/probes/unix/linux/fwupdsecattr_probe.c:238: leaked_storage: Variable "appstream_name" going out of scope leaks the storage it points to.

  3. Defect type: RESOURCE_LEAK
    /src/OVAL/probes/unix/linux/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.

And, as bonus, the 3-rd Commit makes the fwupdsecattr probe test more stable and less dependent on the system configuration.

….c/h

On top of being ugly this code makes compiler unhappy:
OVAL/probes/unix/linux/systemdshared.h:147:12:
   warning[-Wunused-function]: 'get_all_systemd_units' defined but not used
OVAL/probes/unix/linux/systemdshared.h:73:14:
   warning[-Wunused-function]: 'get_path_by_unit' defined but not used
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.
The 'org.fwupd.hsi.Kernel.Lockdown' attribute could be in any of
'not-valid', 'not-enabled' or 'enabled' states, depending on the
system. And we are fine getting any of them.
@evgenyz evgenyz added the bugfix label Jul 20, 2023
@evgenyz evgenyz added this to the 1.3.9 milestone Jul 20, 2023
@evgenyz evgenyz requested a review from jan-cerny July 21, 2023 09:16
@jan-cerny jan-cerny self-assigned this Jul 21, 2023
Copy link
Member

@jan-cerny jan-cerny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look OK to me. Thanks for fixing the leaks!

The CI fail on Rawhide is tracked in #1997 and isn't caused by the contents of this PR.

@jan-cerny jan-cerny merged commit 0862f59 into OpenSCAP:maint-1.3 Jul 21, 2023
15 of 17 checks passed
@evgenyz evgenyz deleted the fix-coverity-1.3.8 branch July 24, 2023 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants