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:20:04 +0000 (18:20 -0400)
commit856af4e3dc2406df7a2baed8058188acca9dbde6
tree5f370dcd1b15a396ba695ec882fa4c26d59b145e
parent4194c2875310c13ee3ca2bb0e1aea6a2ae67c55a
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>
(cherry picked from commit 3e3bfb896e0dd8a54caad9c6264e2452566b4012)
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]