mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-08 09:41:14 +02:00
34543: Prevent crash on garbage bytes inside $(...)
Garbage input (nul bytes, etc.) can cause the $(...) parser to become confused during look-ahead and attempt to back up the input too far. This commit catches the error but does not fix the underlying cause.
This commit is contained in:
parent
dd988542f4
commit
2c13d9fb0d
3 changed files with 13 additions and 4 deletions
|
@ -1,3 +1,8 @@
|
|||
2015-02-14 Barton E. Schaefer <schaefer@zsh.org>
|
||||
|
||||
* 34543: Src/input.c, Src/lex.c: Fix crash on garbage bytes
|
||||
inside $(...)
|
||||
|
||||
2015-02-14 Mikael Magnusson <mikachu@gmail.com>
|
||||
|
||||
* unposted: Doc/Zsh/prompt.yo: Fix typo from 28487.
|
||||
|
|
|
@ -393,12 +393,14 @@ inungetc(int c)
|
|||
if (((inbufflags & INP_LINENO) || !strin) && c == '\n')
|
||||
lineno--;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
else if (!(inbufflags & INP_CONT)) {
|
||||
#ifdef DEBUG
|
||||
/* Just for debugging */
|
||||
fprintf(stderr, "Attempt to inungetc() at start of input.\n");
|
||||
}
|
||||
#endif
|
||||
zerr("Garbled input at %c (binary file as commands?)", c);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* The character is being backed up from a previous input stack
|
||||
|
|
|
@ -503,13 +503,15 @@ cmd_or_math(int cs_type)
|
|||
/* else unsuccessful: unget the whole thing */
|
||||
hungetc(c);
|
||||
lexstop = 0;
|
||||
while (lexbuf.len > oldlen) {
|
||||
while (lexbuf.len > oldlen && !errflag) {
|
||||
lexbuf.len--;
|
||||
hungetc(itok(*--lexbuf.ptr) ?
|
||||
ztokens[*lexbuf.ptr - Pound] : *lexbuf.ptr);
|
||||
}
|
||||
if (errflag)
|
||||
return 2;
|
||||
hungetc('(');
|
||||
return 0;
|
||||
return errflag ? 2 : 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue