summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko2014-12-29 00:04:18 +0100
committerDenys Vlasenko2014-12-29 00:04:18 +0100
commitc76236fd7d980822a647914c9ff6a3fabdec2390 (patch)
tree93b96c77016ad62e5237e2885ec92c6616a690ae /shell
parent8074a6ca4dc4e30e38570b52529b87c547c41b1b (diff)
downloadbusybox-c76236fd7d980822a647914c9ff6a3fabdec2390.zip
busybox-c76236fd7d980822a647914c9ff6a3fabdec2390.tar.gz
ash: fix a SEGV in ${#1}
function old new delta varvalue 760 805 +45 evalvar 648 603 -45 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 90fb00f..c5ad969 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -6746,6 +6746,14 @@ varvalue(char *name, int varflags, int flags, struct strlist *var_str_list)
len = strlen(p);
if (!(subtype == VSPLUS || subtype == VSLENGTH))
memtodest(p, len, syntax, quotes);
+#if ENABLE_UNICODE_SUPPORT
+ if (subtype == VSLENGTH && len > 0) {
+ reinit_unicode_for_ash();
+ if (unicode_status == UNICODE_ON) {
+ len = unicode_strlen(p);
+ }
+ }
+#endif
return len;
}
@@ -6829,15 +6837,7 @@ evalvar(char *p, int flags, struct strlist *var_str_list)
varunset(p, var, 0, 0);
if (subtype == VSLENGTH) {
- ssize_t n = varlen;
- if (n > 0) {
- reinit_unicode_for_ash();
- if (unicode_status == UNICODE_ON) {
- const char *val = lookupvar(var);
- n = unicode_strlen(val);
- }
- }
- cvtnum(n > 0 ? n : 0);
+ cvtnum(varlen > 0 ? varlen : 0);
goto record;
}