diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2009-11-26 11:55:22 +0800 |
---|---|---|
committer | maximilian attems <max@stro.at> | 2010-03-22 00:29:17 +0100 |
commit | 245d8240fb9a0601ec94c80c453befc0f510a0e3 (patch) | |
tree | 93f7102e60d766904dad7571d92f279b53cab29f | |
parent | 74fc1cac1cf99d538b95ea285afd05af6c3fb5e2 (diff) | |
download | klibc-245d8240fb9a0601ec94c80c453befc0f510a0e3.tar.gz |
[klibc] [BUILTIN] Fix off-by-one recordregion in readcmd
Alexey Gladkov <gladkov.alexey@gmail.com> wrote:
>
> I found another example:
>
> $ tr -d '[:print:]' < /etc/passwd |tr -d '\t\n' |wc -c
> 0
>
> $ dash -c 'while read o p; do printf "[%s] [%s]\n" "$o" "$p"; done <
> /etc/passwd' |tr -d '[:print:]' |tr -d '[:space:]' |wc -c
> 61
>
> bug is not fixed yet :(
This bug is caused by an off-by-one error in the recordregion
call in readcmd. It included the terminating NUL in the region
which causes ifsbreakup to include the string after it for scanning.
Setting the correct length fixes the problem.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: maximilian attems <max@stro.at>
-rw-r--r-- | usr/dash/miscbltin.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/usr/dash/miscbltin.c b/usr/dash/miscbltin.c index 7fd5cc9f6db6b..50da2529c1319 100644 --- a/usr/dash/miscbltin.c +++ b/usr/dash/miscbltin.c @@ -85,7 +85,7 @@ readcmd_handle_line(char *line, char **ap, size_t len) backup = sstrdup(line); arglist.lastp = &arglist.list; - recordregion(0, len, 0); + recordregion(0, len - 1, 0); ifsbreakup(s, &arglist); *arglist.lastp = NULL; |