--- src/tail.c.orig 2005-10-07 14:55:13.502248607 +0200 +++ src/tail.c 2005-10-07 14:58:55.000717872 +0200 @@ -64,6 +64,8 @@ /* FIXME: make Follow_name the default? */ #define DEFAULT_FOLLOW_MODE Follow_descriptor +#define MAX_LINE_SIZE (1024*1024) + enum Follow_mode { /* Follow the name of each file: if the file is renamed, try to reopen @@ -524,7 +526,8 @@ size_t total_lines = 0; /* Total number of newlines in all buffers. */ int errors = 0; size_t n_read; /* Size in bytes of most recent read */ - + int total_read = 0; + first = last = xmalloc (sizeof (LBUFFER)); first->nbytes = first->nlines = 0; first->next = NULL; @@ -536,6 +539,13 @@ n_read = safe_read (fd, tmp->buffer, BUFSIZ); if (n_read == 0 || n_read == SAFE_READ_ERROR) break; + + total_read += n_read; + if (total_read > MAX_LINE_SIZE) { + error (0, 0, _("too long line in %s"), quote (pretty_filename)); + break; + } + tmp->nbytes = n_read; *read_pos += n_read; tmp->nlines = 0;