ash: fix corruption of ${#var} if $var contains UTF-8 characters
authorRon Yorston <rmy@pobox.com>
Fri, 18 Mar 2016 11:29:19 +0000 (11:29 +0000)
committerMike Frysinger <vapier@gentoo.org>
Tue, 22 Mar 2016 22:19:29 +0000 (18:19 -0400)
commit3e3bfb896e0dd8a54caad9c6264e2452566b4012
treecf13a882acb6060341acf3bfa3f9a54c3d7d43cb
parent6701e91d84fe499b5d87dc21790cd9d7bcb13220
ash: fix corruption of ${#var} if $var contains UTF-8 characters

As reported in bug 8506:

   $ X=abcdÉfghÍjklmnÓpqrstÚvwcyz
   $ echo ${#X}
   abcd26

The result should be 26.

This regression was introduced by:

   <d68d1fb> 2015-05-18 [Ron Yorston]  ash: code shrink around varvalue

The length in characters was being used to discard the contents of
the variable instead of the length in bytes.

URL: https://bugs.busybox.net/8506
Reported-by: Martijn Dekker <martijn@inlv.org>
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
shell/ash.c
shell/ash_test/ash-vars/var-utf8-length.right [new file with mode: 0644]
shell/ash_test/ash-vars/var-utf8-length.tests [new file with mode: 0755]