← Commit list

fa52ac978

Sören Tempel
Sören Tempel
2022-03-01
SUCCESS Duration: 153s

Subject

ash: don't read past end of var in subvareval for bash substitutions

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+4 -0
@@ -7081,6 +7081,10 @@ subevalvar(char *start, char *str, int strloc,
*repl = '\0';
break;
}
+ if ((unsigned char)*repl == CTLENDVAR) { /* ${v/pattern} (no trailing /, no repl) */
+ repl = NULL;
+ break;
+ }
/* Handle escaped slashes, e.g. "${v/\//_}" (they are CTLESC'ed by this point) */
if ((unsigned char)*repl == CTLESC && repl[1])
repl++;
shell/ash_test/ash-vars/var_bash_repl_unterminated.right+1 -0
@@ -0,0 +1 @@
+b/d
shell/ash_test/ash-vars/var_bash_repl_unterminated.tests+2 -0
@@ -0,0 +1,2 @@
+a=b-c
+echo ${a/-*}/d
shell/hush_test/hush-vars/var_bash_repl_unterminated.right+1 -0
@@ -0,0 +1 @@
+b/d
shell/hush_test/hush-vars/var_bash_repl_unterminated.tests+2 -0
@@ -0,0 +1,2 @@
+a=b-c
+echo ${a/-*}/d