Fix "tail -c 10" segfault spotted by Lukasz Szpakowski.
authorRob Landley <rob@landley.net>
Wed, 19 Nov 2014 20:29:53 +0000 (14:29 -0600)
committerRob Landley <rob@landley.net>
Wed, 19 Nov 2014 20:29:53 +0000 (14:29 -0600)
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

index aba5318..e92c044 100644 (file)
@@ -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;