From d5a33e9150da61d95ad3ae06f6754a6dd101124a Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Sun, 5 Feb 2023 09:50:53 -0700 Subject: fix buffer overflow in countlines for files greater than 32k Signed-off-by: Derek Stevens --- routes/template.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'routes/template.go') diff --git a/routes/template.go b/routes/template.go index 408841a..20d678b 100644 --- a/routes/template.go +++ b/routes/template.go @@ -59,7 +59,7 @@ func countLines(r io.Reader) (int, error) { switch { case err == io.EOF: /* handle last line not having a newline at the end */ - if bufLen >= 1 && buf[bufLen-1] != '\n' { + if bufLen >= 1 && buf[(bufLen-1)%(32*1024)] != '\n' { count++ } return count, nil -- cgit