Cleanup option keyword/environment substitution
authorSteven Lang <tirea@google.com>
Fri, 28 Oct 2011 06:37:13 +0000 (08:37 +0200)
committerJens Axboe <axboe@kernel.dk>
Fri, 28 Oct 2011 06:37:13 +0000 (08:37 +0200)
commitd0c814ececb7410e97d1a437e80fc2dfd5c6de38
tree975cf98b926f8c4a56f4a0939c585de7c6fad8ab
parent2b7c46bd41b3203c2ea6876690a14b1184c741fd
Cleanup option keyword/environment substitution

Right now the substitution for options seems quite fragile.  Among the
issues...

- If bc had an error and returned no output, it caused a NULL reference
- Multiple variable substitutions (For example $ncpus * $pagesize)
caused an error as it tried to run bc after the first, with the second
still text
- Memory leak for every keyword substituted
- Multiplication caused shell wildcard expansion (*) of the current
directory when passing the input to bc
- Shell escape sequences would be parsed on the command line when bc is called
- Potential buffer overrun due to unchecked lengths on the input line

So I did a little cleanup to get rid of the issues.  This patch also
moves the environment variable substitution to run before the keyword
substitution, so an environment variable can now indirectly perform a
keyword substitution.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
options.c
parse.c
parse.h