diff options
| author | Jim Meyering <jim@meyering.net> | 2002-10-08 06:21:31 +0000 |
|---|---|---|
| committer | Jim Meyering <jim@meyering.net> | 2002-10-08 06:21:31 +0000 |
| commit | 5f4fb36645bc959e71b4ad871fa28755325359fc (patch) | |
| tree | 2eb58348a8518310c7b0587214337276e748cd82 /src | |
| parent | 7a58f340c1dc95abdc8a6b3f24b2546e9316514a (diff) | |
| download | coreutils-5f4fb36645bc959e71b4ad871fa28755325359fc.tar.gz coreutils-5f4fb36645bc959e71b4ad871fa28755325359fc.zip | |
(cat): Don't advance the write pointer past the end of the write buffer.
Diffstat (limited to 'src')
| -rw-r--r-- | src/cat.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -265,19 +265,21 @@ cat ( if (outbuf + outsize <= bpout) { char *wp = outbuf; + size_t remaining_bytes; do { if (full_write (STDOUT_FILENO, wp, outsize) != outsize) error (EXIT_FAILURE, errno, _("write error")); wp += outsize; + remaining_bytes = bpout - wp; } - while (wp + outsize <= bpout); + while (outsize <= remaining_bytes); /* Move the remaining bytes to the beginning of the buffer. */ - memmove (outbuf, wp, bpout - wp); - bpout = outbuf + (bpout - wp); + memmove (outbuf, wp, remaining_bytes); + bpout = outbuf + remaining_bytes; } /* Is INBUF empty? */ |
