]> granicus.if.org Git - procps-ng/commitdiff
watch: Don't attempt to ungetc parts of unknown ANSI escape sequences
authorJosh Triplett <josh@joshtriplett.org>
Fri, 8 Jul 2016 07:32:59 +0000 (00:32 -0700)
committerCraig Small <csmall@enc.com.au>
Sat, 9 Jul 2016 05:03:34 +0000 (15:03 +1000)
If process_ansi encountered an unknown character when processing an ANSI
escape sequence, it would ungetc all the characters read so far, except
for the character just read, and the opening '\033['.  ungetting the
middle of the escape sequence does not produce useful results, and also
relies on the unportable assumption that ungetc works on multiple
characters (which glibc does not support).  Discard the characters
instead.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
watch.c

diff --git a/watch.c b/watch.c
index c20780891741f53fccf586ca3890f20cd175c6c1..277807e1a578347e84b47b40b88789d3376ee5b3 100644 (file)
--- a/watch.c
+++ b/watch.c
@@ -217,8 +217,6 @@ static void process_ansi(FILE * fp)
                        break;
                }
                if ((c < '0' || c > '9') && c != ';') {
-                       while (--i >= 0)
-                               ungetc(buf[i], fp);
                        return;
                }
                buf[i] = (char)c;