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

Plug memory leaks #1210

Merged
merged 1 commit into from
Oct 2, 2018
Merged

Plug memory leaks #1210

merged 1 commit into from
Oct 2, 2018

Conversation

jan-cerny
Copy link
Member

Error: RESOURCE_LEAK (CWE-772): [#def28]
openscap-1.3.0_alpha1/src/OVAL/probes/independent/textfilecontent54_probe.c:144:
alloc_fn: Storage is returned from allocation function
"SEXP_string_newf".
openscap-1.3.0_alpha1/src/OVAL/probes/SEAP/sexp-manip.c:616:9: alloc_fn:
Storage is returned from allocation function "SEXP_new".
openscap-1.3.0_alpha1/src/OVAL/probes/SEAP/sexp-manip.c:1587:16:
alloc_fn: Storage is returned from allocation function "malloc".
openscap-1.3.0_alpha1/src/OVAL/probes/SEAP/sexp-manip.c:1587:16:
var_assign: Assigning: "s_exp" = "malloc(16UL)".
openscap-1.3.0_alpha1/src/OVAL/probes/SEAP/sexp-manip.c:1596:9:
return_alloc: Returning allocated memory "s_exp".
openscap-1.3.0_alpha1/src/OVAL/probes/SEAP/sexp-manip.c:616:9:
var_assign: Assigning: "sexp" = "SEXP_new()".
openscap-1.3.0_alpha1/src/OVAL/probes/SEAP/sexp-manip.c:618:9:
identity_transfer: Passing "sexp" as argument 1 to function
"SEXP_string_newf_rv", which returns that argument.
openscap-1.3.0_alpha1/src/OVAL/probes/SEAP/sexp-manip_r.c:288:9:
return_parm: Returning parameter "sexp_mem".
openscap-1.3.0_alpha1/src/OVAL/probes/SEAP/sexp-manip.c:618:9: noescape:
Resource "sexp" is not freed or pointed-to in function
"SEXP_string_newf_rv".
openscap-1.3.0_alpha1/src/OVAL/probes/SEAP/sexp-manip_r.c:243:37:
noescape: "SEXP_string_newf_rv(SEXP_t *, char const *, va_list)" does
not free or save its parameter "sexp_mem".
openscap-1.3.0_alpha1/src/OVAL/probes/SEAP/sexp-manip.c:618:9:
var_assign: Assigning: "sexp" = "SEXP_string_newf_rv(sexp, format, ap)".
openscap-1.3.0_alpha1/src/OVAL/probes/SEAP/sexp-manip.c:621:9:
return_alloc: Returning allocated memory "sexp".
openscap-1.3.0_alpha1/src/OVAL/probes/independent/textfilecontent54_probe.c:144:
var_assign: Assigning: "se_filepath" = storage returned from
"SEXP_string_newf("%s%s", path, filename)".
openscap-1.3.0_alpha1/src/OVAL/probes/independent/textfilecontent54_probe.c:150:
noescape: Resource "se_filepath" is not freed or pointed-to in
"probe_item_create".
openscap-1.3.0_alpha1/src/OVAL/probes/independent/textfilecontent54_probe.c:165:
leaked_storage: Variable "se_filepath" going out of scope leaks the
storage it points to.
163| }
164|
165|-> return item;
166| }
167|

A similar situation for se_instance variable.

Error: RESOURCE_LEAK (CWE-772): [#def28]
openscap-1.3.0_alpha1/src/OVAL/probes/independent/textfilecontent54_probe.c:144:
alloc_fn: Storage is returned from allocation function
"SEXP_string_newf".
openscap-1.3.0_alpha1/src/OVAL/probes/SEAP/sexp-manip.c:616:9: alloc_fn:
Storage is returned from allocation function "SEXP_new".
openscap-1.3.0_alpha1/src/OVAL/probes/SEAP/sexp-manip.c:1587:16:
alloc_fn: Storage is returned from allocation function "malloc".
openscap-1.3.0_alpha1/src/OVAL/probes/SEAP/sexp-manip.c:1587:16:
var_assign: Assigning: "s_exp" = "malloc(16UL)".
openscap-1.3.0_alpha1/src/OVAL/probes/SEAP/sexp-manip.c:1596:9:
return_alloc: Returning allocated memory "s_exp".
openscap-1.3.0_alpha1/src/OVAL/probes/SEAP/sexp-manip.c:616:9:
var_assign: Assigning: "sexp" = "SEXP_new()".
openscap-1.3.0_alpha1/src/OVAL/probes/SEAP/sexp-manip.c:618:9:
identity_transfer: Passing "sexp" as argument 1 to function
"SEXP_string_newf_rv", which returns that argument.
openscap-1.3.0_alpha1/src/OVAL/probes/SEAP/sexp-manip_r.c:288:9:
return_parm: Returning parameter "sexp_mem".
openscap-1.3.0_alpha1/src/OVAL/probes/SEAP/sexp-manip.c:618:9: noescape:
Resource "sexp" is not freed or pointed-to in function
"SEXP_string_newf_rv".
openscap-1.3.0_alpha1/src/OVAL/probes/SEAP/sexp-manip_r.c:243:37:
noescape: "SEXP_string_newf_rv(SEXP_t *, char const *, va_list)" does
not free or save its parameter "sexp_mem".
openscap-1.3.0_alpha1/src/OVAL/probes/SEAP/sexp-manip.c:618:9:
var_assign: Assigning: "sexp" = "SEXP_string_newf_rv(sexp, format, ap)".
openscap-1.3.0_alpha1/src/OVAL/probes/SEAP/sexp-manip.c:621:9:
return_alloc: Returning allocated memory "sexp".
openscap-1.3.0_alpha1/src/OVAL/probes/independent/textfilecontent54_probe.c:144:
var_assign: Assigning: "se_filepath" = storage returned from
"SEXP_string_newf("%s%s", path, filename)".
openscap-1.3.0_alpha1/src/OVAL/probes/independent/textfilecontent54_probe.c:150:
noescape: Resource "se_filepath" is not freed or pointed-to in
"probe_item_create".
openscap-1.3.0_alpha1/src/OVAL/probes/independent/textfilecontent54_probe.c:165:
leaked_storage: Variable "se_filepath" going out of scope leaks the
storage it points to.
  163|   	}
  164|
  165|-> 	return item;
  166|   }
  167|

A similar situation for se_instance variable.
@jan-cerny jan-cerny added this to the 1.2.18 milestone Oct 2, 2018
@codecov
Copy link

codecov bot commented Oct 2, 2018

Codecov Report

Merging #1210 into maint-1.2 will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@              Coverage Diff              @@
##           maint-1.2    #1210      +/-   ##
=============================================
- Coverage      61.77%   61.76%   -0.01%     
=============================================
  Files            291      291              
  Lines          47485    47487       +2     
=============================================
- Hits           29332    29330       -2     
- Misses         18153    18157       +4
Impacted Files Coverage Δ
src/OVAL/probes/independent/textfilecontent54.c 87.55% <100%> (+0.11%) ⬆️
src/CPE/cpelang.c 65.07% <0%> (-3.18%) ⬇️
src/CPE/cpename.c 80% <0%> (-0.55%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cdf1ef8...9ef235a. Read the comment docs.

@matejak matejak self-assigned this Oct 2, 2018
@matejak matejak added the bug label Oct 2, 2018
@matejak
Copy link
Contributor

matejak commented Oct 2, 2018

Great, it looks like that probe_item_create makes deep-copy of passed SEXPs, as test pass.
LGTU, thanks!

@matejak matejak merged commit b2d6c17 into OpenSCAP:maint-1.2 Oct 2, 2018
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