From 2916e6ff9c754b848fdf8ab698512d8ea9b99d97 Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Mon, 24 Nov 2014 09:14:44 +0000 Subject: paste: fix possible truncated output with large files If '\n' was present at the size_t boundary of a file, then that and subsequent data would be discarded. * src/paste.c (paste_parallel): Avoid the overflow issue by changing the flag to a boolean rather than a count. * NEWS: Mention the bug fix. (cherry picked from commit 16e2347bd545057b04a97115563e606ad822ec33) Conflicts: NEWS --- src/paste.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/paste.c b/src/paste.c index 3663aaf..7e67f56 100644 --- a/src/paste.c +++ b/src/paste.c @@ -235,7 +235,7 @@ paste_parallel (size_t nfiles, char **fnamptr) { int chr IF_LINT ( = 0); /* Input character. */ int err IF_LINT ( = 0); /* Input errno value. */ - size_t line_length = 0; /* Number of chars in line. */ + bool sometodo = false; /* Input chars to process. */ if (fileptr[i]) { @@ -250,7 +250,7 @@ paste_parallel (size_t nfiles, char **fnamptr) while (chr != EOF) { - line_length++; + sometodo = true; if (chr == '\n') break; xputchar (chr); @@ -259,7 +259,7 @@ paste_parallel (size_t nfiles, char **fnamptr) } } - if (line_length == 0) + if (! sometodo) { /* EOF, read error, or closed file. If an EOF or error, close the file. */ -- 1.7.12.1