Commit e119901e authored by John Johansen's avatar John Johansen Committed by Steve Beattie

parser: fix output of listen and setopts commands

The listen and setopts commands have broken encodings because the
tmp stream they use to handle diverging from the other commands
has does not set its write position to to the end of the copied data.
Instead the write head is set to the beginning so that when the
new data for the command is written it overwrites the begging of
the command instead of appending to it.
Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
Acked-by: default avatarSeth Arnold <seth.arnold@canonical.com>
parent 4a616e35
......@@ -312,7 +312,7 @@ bool unix_rule::write_label(std::ostringstream &buffer, const char *label)
*/
int unix_rule::gen_policy_re(Profile &prof)
{
std::ostringstream buffer, tmp;
std::ostringstream buffer;
std::string buf;
int mask = mode;
......@@ -367,7 +367,8 @@ int unix_rule::gen_policy_re(Profile &prof)
}
if (mask & AA_NET_LISTEN) {
tmp.str(buffer.str());
std::ostringstream tmp(buffer.str());
tmp.seekp(0, ios_base::end);
tmp << "\\x" << std::setfill('0') << std::setw(2) << std::hex << CMD_LISTEN;
/* TODO: backlog conditional: for now match anything*/
tmp << "..";
......@@ -379,7 +380,8 @@ int unix_rule::gen_policy_re(Profile &prof)
goto fail;
}
if (mask & AA_NET_OPT) {
tmp.str(buffer.str());
std::ostringstream tmp(buffer.str());
tmp.seekp(0, ios_base::end);
tmp << "\\x" << std::setfill('0') << std::setw(2) << std::hex << CMD_OPT;
/* TODO: sockopt conditional: for now match anything */
tmp << "..";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment