mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-22 01:57:43 +00:00
Merge parser misc fixes (memory leaks, restoring ostream format)
Closes #533 MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1760 Approved-by: Steve Beattie <steve+gitlab@nxnw.org> Merged-by: Steve Beattie <steve+gitlab@nxnw.org>
This commit is contained in:
commit
51bdbec119
@ -570,6 +570,8 @@ ostream &mnt_rule::dump(ostream &os)
|
||||
{
|
||||
prefix_rule_t::dump(os);
|
||||
|
||||
std::ios::fmtflags fmt(os.flags());
|
||||
|
||||
if (perms & AA_MAY_MOUNT)
|
||||
os << "mount";
|
||||
else if (perms & AA_MAY_UMOUNT)
|
||||
@ -603,6 +605,7 @@ ostream &mnt_rule::dump(ostream &os)
|
||||
os << " " << "(0x" << hex << perms << "/0x" << (audit != AUDIT_UNSPECIFIED ? perms : 0) << ")";
|
||||
os << ",\n";
|
||||
|
||||
os.flags(fmt);
|
||||
return os;
|
||||
}
|
||||
|
||||
|
@ -133,8 +133,10 @@ static void process_entries(const void *nodep, VISIT value, int level unused)
|
||||
if (entry->link_name &&
|
||||
strncmp((*t)->from, entry->link_name, len) == 0) {
|
||||
char *n = do_alias(*t, entry->link_name);
|
||||
if (!n)
|
||||
if (!n) {
|
||||
free_cod_entries(dup);
|
||||
return;
|
||||
}
|
||||
if (!dup)
|
||||
dup = copy_cod_entry(entry);
|
||||
free(dup->link_name);
|
||||
|
@ -188,24 +188,21 @@ cleanup:
|
||||
if (prof->attachment) {
|
||||
tmp = symtab::delete_var(PROFILE_EXEC_VAR);
|
||||
delete tmp;
|
||||
if (saved_exec_path) {
|
||||
if (saved_exec_path)
|
||||
symtab::add_var(*saved_exec_path);
|
||||
delete saved_exec_path;
|
||||
}
|
||||
}
|
||||
cleanup_attach:
|
||||
if (prof->attachment) {
|
||||
tmp = symtab::delete_var(PROFILE_ATTACH_VAR);
|
||||
delete tmp;
|
||||
if (saved_attach_path) {
|
||||
if (saved_attach_path)
|
||||
symtab::add_var(*saved_attach_path);
|
||||
delete saved_attach_path;
|
||||
}
|
||||
}
|
||||
cleanup_name:
|
||||
tmp = symtab::delete_var(PROFILE_NAME_VARIABLE);
|
||||
delete tmp;
|
||||
|
||||
delete saved_exec_path;
|
||||
delete saved_attach_path;
|
||||
out:
|
||||
return error;
|
||||
}
|
||||
|
@ -431,11 +431,14 @@ public:
|
||||
ostream &dump(ostream &os) override {
|
||||
class_rule_t::dump(os);
|
||||
|
||||
std::ios::fmtflags fmt(os.flags());
|
||||
|
||||
if (saved)
|
||||
os << "(0x" << std::hex << perms << "/orig " << saved << ") ";
|
||||
else
|
||||
os << "(0x" << std::hex << perms << ") ";
|
||||
|
||||
os.flags(fmt);
|
||||
return os;
|
||||
}
|
||||
|
||||
@ -460,7 +463,11 @@ public:
|
||||
ostream &dump(ostream &os) override {
|
||||
class_rule_t::dump(os);
|
||||
|
||||
std::ios::fmtflags fmt(os.flags());
|
||||
|
||||
os << "(0x" << std::hex << perms << ") ";
|
||||
|
||||
os.flags(fmt);
|
||||
return os;
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ static void trim_trailing_slash(std::string& str)
|
||||
str.clear(); // str is all '/'
|
||||
}
|
||||
|
||||
int copy_value_to_name(std::string value, char **name)
|
||||
int copy_value_to_name(const std::string& value, char **name)
|
||||
{
|
||||
free(*name);
|
||||
*name = strdup(value.c_str());
|
||||
@ -307,6 +307,7 @@ int variable::expand_variable()
|
||||
}
|
||||
name = variable::process_var(var.c_str());
|
||||
variable *ref = symtab::lookup_existing_symbol(name);
|
||||
free(name);
|
||||
if (!ref) {
|
||||
PERROR("Failed to find declaration for: %s\n", var.c_str());
|
||||
rc = 1;
|
||||
@ -336,7 +337,6 @@ int variable::expand_variable()
|
||||
}
|
||||
|
||||
out:
|
||||
free(name);
|
||||
expanding = false;
|
||||
return rc;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user