From ef56e60e06571fa2217ead07e91054c1ca41845d Mon Sep 17 00:00:00 2001 From: John Johansen Date: Fri, 25 Aug 2023 23:49:32 -0700 Subject: [PATCH] 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 --- parser/profile.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/parser/profile.cc b/parser/profile.cc index d82330f15..a542a8ff1 100644 --- a/parser/profile.cc +++ b/parser/profile.cc @@ -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