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

libselinux: abnormal branches may cause memory leakage. #373

Open
lujiev opened this issue Oct 28, 2022 · 0 comments
Open

libselinux: abnormal branches may cause memory leakage. #373

lujiev opened this issue Oct 28, 2022 · 0 comments

Comments

@lujiev
Copy link
Contributor

lujiev commented Oct 28, 2022

the func __policy_init() In the libselinux/src/audit2why.c
It maybe cause memory leak when the function returns 1 after invokes function calloc() and sepol_policy_file_create() successfully.

    avc = calloc(sizeof(struct avc_t), 1);
if (!avc) {
	...
	return 1;
}

if (sepol_policy_file_create(&pf) ||
    sepol_policydb_create(&avc->policydb)) {
	snprintf(errormsg, sizeof(errormsg), 
		 "policydb_init failed: %m\n");
	PyErr_SetString( PyExc_RuntimeError, errormsg);
	fclose(fp);
           ############maybe case a memory leak for avc #######
	return 1;
}
sepol_policy_file_set_fp(pf, fp);	
if (sepol_policydb_read(avc->policydb, pf)) {
	snprintf(errormsg, sizeof(errormsg), 
		 "invalid binary policy %s\n", curpolicy);
	PyErr_SetString( PyExc_ValueError, errormsg);
	fclose(fp);
            ############maybe case a memory leak for avc and pf #######
	return 1;
}
    ...
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

No branches or pull requests

1 participant