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

Merge maint-1.2 #1221

Merged
merged 23 commits into from
Oct 3, 2018
Merged

Merge maint-1.2 #1221

merged 23 commits into from
Oct 3, 2018

Conversation

jan-cerny
Copy link
Member

This PR merges maint-1.2 to master.

jan-cerny and others added 23 commits September 27, 2018 10:57
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.
Extracted the process into a function and called it where it was missing.
Do not free oscap_source when parsing cvrf_xml for index.
It should not be the duty of cvrf xml parsing function to free its
source of input.

Plus, cvrf_index_import is also called in function
cvrf_session_new_from_source. In cvrf_session structure,
the import source is part of the strucutre along with cvrf index, it
make no sense to free it.
`fix_text` is allocated in `_xccdf_fix_decode_xml` and was possibly freed in `_write_text_to_fd_and_free`,
but in meantime could have been be jumped over free, causing a memory leak.
Error: RESOURCE_LEAK (CWE-772): [#def9]
openscap-1.3.0_alpha1/src/CVRF/cvrf_priv.c:1659: alloc_fn: Storage is
returned from allocation function "oscap_element_string_copy".
openscap-1.3.0_alpha1/src/common/elements.c:134:3: alloc_fn: Storage is
returned from allocation function "calloc".
openscap-1.3.0_alpha1/src/common/elements.c:134:3: return_alloc_fn:
Directly returning storage allocated by "calloc".
openscap-1.3.0_alpha1/src/CVRF/cvrf_priv.c:1659: noescape: Resource
"oscap_element_string_copy(reader)" is not freed or pointed-to in
"oscap_stringlist_add_string".
openscap-1.3.0_alpha1/src/common/list.c:353:77: noescape:
"oscap_stringlist_add_string(struct oscap_stringlist *, char const *)"
does not free or save its parameter "str".
openscap-1.3.0_alpha1/src/CVRF/cvrf_priv.c:1659: leaked_storage: Failing
to save or free storage allocated by "oscap_element_string_copy(reader)"
leaks it.
 1657|   			score_set->vector =
oscap_element_string_copy(reader);
 1658|   		} else if
(xmlStrcmp(xmlTextReaderConstLocalName(reader), TAG_PRODUCT_ID) == 0) {
 1659|->
oscap_stringlist_add_string(score_set->product_ids,
oscap_element_string_copy(reader));
 1660|   		} else if
(xmlStrcmp(xmlTextReaderConstLocalName(reader), TAG_BASE_SCORE) == 0) {
 1661|   			cvrf_score_set_add_metric(score_set,
CVSS_BASE, oscap_element_string_copy(reader));
…_leaks_maint-1.2

Add missing 'free' calls to src/OVAL/probes/probe/worker.c (maint-1.2 branch)
Stable_free complements Stable_new.
Fixed a memory leak, introduced Stable_free.
…eap-command

OVAL/probes/SEAP/seap-command.c: fixed memory leaks
…rce_when_parsing_cvrf_xml

Don't free oscap_source when parsing cvrf_xml
Also extracted non-trivial generation of probe items to functions.
Make sure that intermediate results are freed.
…erity_false_positive

OVAL/probes/SEAP/sexp-manip.c: fixed false positives reported by coverity
 Conflicts:
	src/OVAL/probes/SEAP/seap-command-backendS.c
	src/OVAL/probes/probe/worker.c
@jan-cerny jan-cerny added this to the 1.3.0_alpha3 milestone Oct 3, 2018
@matejak
Copy link
Contributor

matejak commented Oct 3, 2018

LGTM, if tests pass, I am in favor of merge.

@matejak
Copy link
Contributor

matejak commented Oct 3, 2018

test this please

@matejak matejak mentioned this pull request Oct 3, 2018
@codecov
Copy link

codecov bot commented Oct 3, 2018

Codecov Report

Merging #1221 into master will decrease coverage by 0.02%.
The diff coverage is 17.91%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1221      +/-   ##
==========================================
- Coverage   61.85%   61.83%   -0.03%     
==========================================
  Files         275      275              
  Lines       45164    45203      +39     
==========================================
+ Hits        27936    27950      +14     
- Misses      17228    17253      +25
Impacted Files Coverage Δ
src/OVAL/probes/probe-api.c 69.56% <ø> (ø) ⬆️
...L/probes/unix/linux/selinuxsecuritycontext_probe.c 0% <0%> (ø) ⬆️
src/OVAL/probes/unix/process_probe.c 0% <0%> (ø) ⬆️
src/CVRF/cvrf_priv.c 55.27% <0%> (-0.04%) ⬇️
utils/oscap-cvrf.c 0% <0%> (ø) ⬆️
src/OVAL/probes/SEAP/seap-command-backendS.c 0% <0%> (ø) ⬆️
src/XCCDF_POLICY/xccdf_policy_remediate.c 58.77% <100%> (+0.07%) ⬆️
.../OVAL/probes/independent/textfilecontent54_probe.c 86.3% <100%> (+0.12%) ⬆️
src/OVAL/probes/SEAP/seap-command.c 47.82% <22.22%> (-0.94%) ⬇️
src/OVAL/probes/SEAP/sexp-manip.c 62.33% <66.66%> (+0.15%) ⬆️
... and 2 more

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 a1f3f68...c3401fb. Read the comment docs.

@jan-cerny jan-cerny merged commit 1171255 into OpenSCAP:master Oct 3, 2018
@jan-cerny jan-cerny removed this from the 1.3.0_alpha3 milestone Oct 8, 2018
@jan-cerny jan-cerny added this to the 1.3.0 milestone Oct 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants