diff options
author | Tobias Klauser <tklauser@xenon.tklauser.home> | 2006-05-09 16:38:30 +0200 |
---|---|---|
committer | Tobias Klauser <tklauser@xenon.tklauser.home> | 2006-05-09 16:38:30 +0200 |
commit | fd58837bf186c49a681f0c498cbaa17a87b69408 (patch) | |
tree | e86b929d32e427bae60bb9dde599e2617c4dfbd5 | |
parent | 4a9fb7b898aa0c14a0c75a716ff00f6567b0eefc (diff) |
Check for block_size bigger than BUFFER_SIZE in watch_file
-rw-r--r-- | simpletail.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/simpletail.c b/simpletail.c index 196dfe2..fa47668 100644 --- a/simpletail.c +++ b/simpletail.c @@ -141,13 +141,20 @@ static int watch_file(const char *filename, off_t offset) return -1; } - /* XXX: block_size could be bigger than BUFFER_SIZE */ block_size = finfo.st_size - offset; + if (block_size < 0) block_size = 0; + /* XXX: Dirty hack for now to make sure + * block_size doesn't get bigger than + * BUFFER_SIZE + */ + if (block_size > BUFFER_SIZE) + block_size = BUFFER_SIZE; + lseek(ffd, offset, SEEK_SET); - while (read(ffd, &fbuf, BUFFER_SIZE) != 0) { + while (read(ffd, &fbuf, block_size) != 0) { write(STDOUT_FILENO, fbuf, block_size); } |