From 802d514789412c0520826cdc1081a62b6f1708c0 Mon Sep 17 00:00:00 2001 From: Steven Schubiger Date: Mon, 21 Mar 2016 16:48:09 +0100 Subject: Terminate buffer with single NUL --- colorize.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'colorize.c') diff --git a/colorize.c b/colorize.c index eb2be2f..16094c6 100644 --- a/colorize.c +++ b/colorize.c @@ -745,10 +745,10 @@ read_print_stream (bool bold, const struct color **colors, const char *file, FIL size_t bytes_read; char *eol; const char *line; - memset (buf, '\0', BUF_SIZE + 1); bytes_read = fread (buf, 1, BUF_SIZE, stream); if (bytes_read != BUF_SIZE && ferror (stream)) vfprintf_fail (formats[FMT_ERROR], BUF_SIZE, "read"); + buf[bytes_read] = '\0'; line = buf; while ((eol = strpbrk (line, "\n\r"))) { -- cgit v1.2.3