kvx: asan: out-of-bounds read
authorAlan Modra <amodra@gmail.com>
Tue, 22 Aug 2023 22:48:39 +0000 (08:18 +0930)
committerAlan Modra <amodra@gmail.com>
Wed, 23 Aug 2023 01:33:52 +0000 (11:03 +0930)
commit847fb383d83039b194f68d9e09974a3de4095eb5
tree8dc777d49be7cb4c0e4a7ff6776b13897ee1efa8
parentc5ed8c6376e755e0a138be4a30469caa6611a5f7
kvx: asan: out-of-bounds read

kvx-parse.c:parse_with_restarts does
  if (!tok.insn[tok.begin])
    tok.class_id = -3;
then a little later
  printf_debug (1, "\nEntering rule: %d (Trying to match: (%s)[%d])\n", jump_target,
TOKEN_NAME (CLASS_ID (tok)), CLASS_ID (tok));

This results in a buffer overrun in TOKEN_NAME.  Fix that.

* config/tc-kvx.h (TOKEN_NAME): Check for tok <= 0, not just -1.
gas/config/tc-kvx.h