Merge parser: fix coverity scan 553075

coverity is reporting an overrun of the profile_mode_table

217     		if (merge_profile_mode(mode, rhs.mode) == MODE_CONFLICT)
>>>     CID 322989:    (OVERRUN)
>>>     Overrunning array "profile_mode_table" of 6 8-byte elements at element index 6 (byte offset 55) using index "this->mode" (which evaluates to 6).

this is because it is being indexed by the profile_mode enum which can
go up to a 6th entry. The code tests for MODE_CONFLICT before using
the table so it shouldn't trigger a bug today, but play it safe for
the future and also get rid of the coverity scan error by adding a
"conflict" entry to the mode_table.

Signed-off-by: John Johansen <john.johansen@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1098
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: John Johansen <john@jjmx.net>
This commit is contained in:
John Johansen 2023-08-28 22:05:45 +00:00
commit 327588f019

View file

@ -27,7 +27,8 @@ const char *profile_mode_table[] = {
"complain",
"kill",
"unconfined",
"prompt"
"prompt",
"conflict" /* should not ever be displayed */
};
bool deref_profileptr_lt::operator()(Profile * const &lhs, Profile * const &rhs) const