diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-13 18:22:35 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-13 18:22:35 +0100 |
commit | 25d9b91d94688b9b022224b95c06cbd4b75da085 (patch) | |
tree | 6d3b5dd63f3fab3fba018c73ae4bc64e5a38b150 /shell/shell_common.c | |
parent | 03d81ef43aca1808255d1a2a19ec394ed805eee8 (diff) |
shell/read: check that variable names are sane
function old new delta
shell_builtin_read 1000 1055 +55
parse_command 1460 1463 +3
builtin_umask 121 123 +2
is_well_formed_var_name 73 66 -7
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/shell_common.c')
-rw-r--r-- | shell/shell_common.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/shell/shell_common.c b/shell/shell_common.c index 99bb91c6f..669a18dfd 100644 --- a/shell/shell_common.c +++ b/shell/shell_common.c @@ -19,8 +19,17 @@ #include "libbb.h" #include "shell_common.h" -#if IFS_BROKEN const char defifsvar[] ALIGN1 = "IFS= \t\n"; -#else -const char defifs[] ALIGN1 = " \t\n"; -#endif + + +int FAST_FUNC is_well_formed_var_name(const char *s, char terminator) +{ + if (!s || !(isalpha(*s) || *s == '_')) + return 0; + + do + s++; + while (isalnum(*s) || *s == '_'); + + return *s == terminator; +} |