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/builtin_read.c | |
parent | 03d81ef43aca1808255d1a2a19ec394ed805eee8 (diff) | |
download | busybox-w32-25d9b91d94688b9b022224b95c06cbd4b75da085.tar.gz busybox-w32-25d9b91d94688b9b022224b95c06cbd4b75da085.tar.bz2 busybox-w32-25d9b91d94688b9b022224b95c06cbd4b75da085.zip |
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/builtin_read.c')
-rw-r--r-- | shell/builtin_read.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/shell/builtin_read.c b/shell/builtin_read.c index 73b0949cf..954e4cd14 100644 --- a/shell/builtin_read.c +++ b/shell/builtin_read.c | |||
@@ -39,6 +39,7 @@ shell_builtin_read(void FAST_FUNC (*setvar)(const char *name, const char *val), | |||
39 | unsigned end_ms; /* -t TIMEOUT */ | 39 | unsigned end_ms; /* -t TIMEOUT */ |
40 | int fd; /* -u FD */ | 40 | int fd; /* -u FD */ |
41 | int nchars; /* -n NUM */ | 41 | int nchars; /* -n NUM */ |
42 | char **pp; | ||
42 | char *buffer; | 43 | char *buffer; |
43 | struct termios tty, old_tty; | 44 | struct termios tty, old_tty; |
44 | const char *retval; | 45 | const char *retval; |
@@ -46,6 +47,16 @@ shell_builtin_read(void FAST_FUNC (*setvar)(const char *name, const char *val), | |||
46 | int startword; | 47 | int startword; |
47 | smallint backslash; | 48 | smallint backslash; |
48 | 49 | ||
50 | pp = argv; | ||
51 | while (*pp) { | ||
52 | if (!is_well_formed_var_name(*pp, '\0')) { | ||
53 | /* Mimic bash message */ | ||
54 | bb_error_msg("read: '%s': not a valid identifier", *pp); | ||
55 | return (const char *)(uintptr_t)1; | ||
56 | } | ||
57 | pp++; | ||
58 | } | ||
59 | |||
49 | nchars = 0; /* if != 0, -n is in effect */ | 60 | nchars = 0; /* if != 0, -n is in effect */ |
50 | if (opt_n) { | 61 | if (opt_n) { |
51 | nchars = bb_strtou(opt_n, NULL, 10); | 62 | nchars = bb_strtou(opt_n, NULL, 10); |