expand: Fix out-of-bounds syntax table access

mbtodest passes a signed byte to chtodest. Bytes with the high bit set
can therefore be negative. The syntax tables are based at SYNBASE so
that signed character values can be used as indices. However, the
is_type path did not apply this offset, causing chtodest and mbtodest
to read before the array:

  $ printf 'v=\377\nw=$v\n' | src/dash
  AddressSanitizer: global-buffer-overflow in chtodest

Apply SYNBASE to is_type, as is already done by the is_special macro.

Fixes: c0c860df08c9 ("expand: Count multi-byte characters for VSLENGTH")
Signed-off-by: Ayesha Shafique <ayeshashafique123@gmail.com>
Tested-by: Anders Kaseorg <andersk@mit.edu>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 file changed
tree: 112eaa22c67e4439dfe3d39ddd5931c367d8420c
  1. src/
  2. .gitignore
  3. autogen.sh
  4. ChangeLog
  5. ChangeLog.O
  6. configure.ac
  7. COPYING
  8. Makefile.am