2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-22 10:07:12 +00:00

parser: fix coverity's "not restoring ostream format"

Save the ostream flags and restore them after the std::hex
modification.

Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
This commit is contained in:
Georgia Garcia 2025-08-04 18:49:24 -03:00
parent 05458768cf
commit 3faddfcf46
2 changed files with 10 additions and 0 deletions

View File

@ -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;
}

View File

@ -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;
}