From 159a7f1621eecf6cf3c2824ffb762a19bf5f7667 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Wed, 19 Nov 2014 14:29:53 -0600 Subject: Fix "tail -c 10" segfault spotted by Lukasz Szpakowski. Once we've read through the initial TT.bytes backlog we discard the extra data, meaning we adjust the remaining amount each time so the overflow is zero bytes. We were doing the adjustment right, but not zeroing out the overflow counter after we did so. --- toys/posix/tail.c | 1 + 1 file changed, 1 insertion(+) (limited to 'toys/posix/tail.c') diff --git a/toys/posix/tail.c b/toys/posix/tail.c index aba53180..e92c0446 100644 --- a/toys/posix/tail.c +++ b/toys/posix/tail.c @@ -164,6 +164,7 @@ static void do_tail(int fd, char *name) } list->data += bytes; list->len -= bytes; + bytes = 0; } } else { int len = new->len, count; -- cgit v1.2.3