← Commit list

f02c82f38

Denys Vlasenko
Denys Vlasenko
2010-08-06
FAILED Duration: 47s

Subject

ash: fix dequoting error detected by var_bash4 test

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

shell/ash.c+6 -7
@@ -6267,7 +6267,7 @@ varunset(const char *end, const char *var, const char *umsg, int varflags)
#if ENABLE_ASH_BASH_COMPAT
static char *
-parse_sub_pattern(char *arg, int inquotes)
+parse_sub_pattern(char *arg, int varflags)
{
char *idx, *repl = NULL;
unsigned char c;
@@ -6285,7 +6285,7 @@ parse_sub_pattern(char *arg, int inquotes)
}
}
*idx++ = c;
- if (!inquotes && c == '\\' && arg[1] == '\\')
+ if (!(varflags & VSQUOTE) && c == '\\' && arg[1] == '\\')
arg++; /* skip both \\, not just first one */
arg++;
}
@@ -6427,7 +6427,7 @@ subevalvar(char *p, char *varname, int strloc, int subtype,
char *idx, *end;
if (!repl) {
- repl = parse_sub_pattern(str, varflags & VSQUOTE);
+ repl = parse_sub_pattern(str, varflags);
//bb_error_msg("repl:'%s'", repl);
if (!repl)
repl = nullstr;
@@ -6496,12 +6496,11 @@ subevalvar(char *p, char *varname, int strloc, int subtype,
}
if (subtype == VSREPLACE) {
+ //bb_error_msg("tail:'%s', quotes:%x", idx, quotes);
while (*idx) {
char *restart_detect = stackblock();
- if (quotes && *idx == '\\') {
- STPUTC(CTLESC, expdest);
- len++;
- }
+ if (quotes && (unsigned char)*idx == CTLESC)
+ idx++;
STPUTC(*idx, expdest);
if (stackblock() != restart_detect)
goto restart;