mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
Merge aa-status: Fix malformed json output with unconfined processes
As reported in issue #295, the json output from aa-status would be invalid if
there were profiles defined for processes that were unconfined. Fix this by
ensuring the json for the processes array is closed properly.
Signed-off-by: Alex Murray <alex.murray@canonical.com>
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/964
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit dfc9847f89
)
Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
parent
aa10832801
commit
099ad8186a
1 changed files with 5 additions and 2 deletions
|
@ -534,16 +534,19 @@ static int detailed_output(FILE *json) {
|
|||
} else {
|
||||
fprintf(json, "%s\"%s\": [{\"profile\": \"%s\", \"pid\": \"%s\", \"status\": \"%s\"}",
|
||||
// first element will be a unique executable
|
||||
i == 0 && j == 0 ? "" : "], ",
|
||||
j == 0 ? "" : "], ",
|
||||
filtered[j].exe, filtered[j].profile, filtered[j].pid, filtered[j].mode);
|
||||
}
|
||||
|
||||
}
|
||||
if (j > 0) {
|
||||
fprintf(json, "]");
|
||||
}
|
||||
}
|
||||
free_processes(filtered, nfiltered);
|
||||
}
|
||||
if (json) {
|
||||
fprintf(json, "%s}}\n", nprocesses > 0 ? "]" : "");
|
||||
fprintf(json, "}}\n");
|
||||
}
|
||||
|
||||
exit:
|
||||
|
|
Loading…
Add table
Reference in a new issue