From: Simon Glass Date: Sat, 9 Jun 2018 12:22:27 -0600 Subject: [U-Boot] [PATCH 1/8] log: Fix incorect range check in log_get_cat_name() In-Reply-To: <20180609182235.33532-1-sjg@chromium.org> References: <20180609182235.33532-1-sjg@chromium.org> Message-ID: <20180609182235.33532-2-sjg@chromium.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de This allows access to an element after the end of the array. Fix it. Reported-by: Coverity (CID: 173279) Signed-off-by: Simon Glass --- common/log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/log.c b/common/log.c index 3b5588ebe7..4e488eca5b 100644 --- a/common/log.c +++ b/common/log.c @@ -38,7 +38,7 @@ static const char *log_level_name[LOGL_COUNT] = { const char *log_get_cat_name(enum log_category_t cat) { - if (cat > LOGC_COUNT) + if (cat >= LOGC_COUNT) return "invalid"; if (cat >= LOGC_NONE) return log_cat_name[cat - LOGC_NONE]; -- 2.18.0.rc1.242.g61856ae69a-goog