hush: fix a signedness bug
authorDenys Vlasenko <vda.linux@googlemail.com>
Fri, 30 Mar 2018 22:46:07 +0000 (00:46 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 30 Mar 2018 22:48:18 +0000 (00:48 +0200)
Testcase:

set -- a ""; space=" "; printf "<%s>\n" "$@"$space

Before:
<a >
After:
<a>
<>

It usually does not bite since bbox forces -funsigned-char build.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
shell/hush.c

index e6dd1bc3d9421f9b2c33700d74d8fa777c35c105..01d8f5935d94e15c23ad8defc9bca5fdfc03d7ce 100644 (file)
@@ -6126,7 +6126,7 @@ static NOINLINE int expand_vars_to_list(o_string *output, int n, char *arg)
                        } else
                        /* If EXP_FLAG_SINGLEWORD, we handle assignment 'a=....$@.....'
                         * and in this case should treat it like '$*' - see 'else...' below */
-                       if (first_ch == ('@'|0x80)  /* quoted $@ */
+                       if (first_ch == (char)('@'|0x80)  /* quoted $@ */
                         && !(output->o_expflags & EXP_FLAG_SINGLEWORD) /* not v="$@" case */
                        ) {
                                while (1) {