From: Daniel Kolesa Date: Sun, 4 Oct 2015 13:52:36 +0000 (+0100) Subject: eolian: fix out-of-bounds indexing on tokens X-Git-Tag: v1.16.0-alpha1~17 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cc0476041f9d879adf8a0af9813c3193fc495c96;p=platform%2Fupstream%2Fefl.git eolian: fix out-of-bounds indexing on tokens Fixes CID 1324818 @fix --- diff --git a/src/lib/eolian/eo_lexer.c b/src/lib/eolian/eo_lexer.c index bd78958..d14c70f 100644 --- a/src/lib/eolian/eo_lexer.c +++ b/src/lib/eolian/eo_lexer.c @@ -1148,8 +1148,9 @@ eo_lexer_token_to_str(int token, char *buf) { const char *v; size_t idx = token - START_CUSTOM; - if (idx >= sizeof(tokens)) - v = keywords[idx - sizeof(tokens)]; + size_t tsz = sizeof(tokens) / sizeof(tokens[0]); + if (idx >= tsz) + v = keywords[idx - tsz]; else v = tokens[idx]; memcpy(buf, v, strlen(v) + 1);