summaryrefslogtreecommitdiffstats
path: root/src/core/exec.c
diff options
context:
space:
mode:
authorMichael Brown2010-11-23 01:18:11 +0100
committerMichael Brown2010-11-23 01:18:11 +0100
commit66679fe7dff6e71d333e41a3bfd9f351f537678c (patch)
treebcf6a9bfacef113ef507cc8e4dbfb008a230b39e /src/core/exec.c
parent[cmdline] Fix multi-layer variable expansion (diff)
downloadipxe-66679fe7dff6e71d333e41a3bfd9f351f537678c.tar.gz
ipxe-66679fe7dff6e71d333e41a3bfd9f351f537678c.tar.xz
ipxe-66679fe7dff6e71d333e41a3bfd9f351f537678c.zip
[cmdline] Fix multi-layer variable expansion (again)
Expansion of the (admittedly perverse) "aaa}bbb${ccc" will currently fail because expand_command() does not check that the closing "}" occurs later than the opening "${". Fix by ensuring that the most recent opening "${" is used to match against the first *subsequent* closing "}". Total cost of this change: -12 bytes, bringing the overall cost of this feature to -4 bytes. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/core/exec.c')
-rw-r--r--src/core/exec.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/core/exec.c b/src/core/exec.c
index 18fc57f5..d96b8a76 100644
--- a/src/core/exec.c
+++ b/src/core/exec.c
@@ -121,12 +121,12 @@ static char * expand_command ( const char *command ) {
for ( tmp = expcmd ; *tmp ; tmp++ ) {
if ( ( tmp[0] == '$' ) && ( tmp[1] == '{' ) )
start = tmp;
- if ( tmp[0] == '}' )
+ if ( start && ( tmp[0] == '}' ) ) {
end = tmp;
- if ( start && end )
break;
+ }
}
- if ( ! ( start && end ) )
+ if ( ! end )
break;
*start = '\0';
name = ( start + 2 );