fix buffer overflow in countlines for files greater than 32k Signed-off-by: Derek Stevens <nilix@nilfm.cc>
Derek Stevens nilix@nilfm.cc
Sun, 05 Feb 2023 09:50:53 -0700
1 files changed,
1 insertions(+),
1 deletions(-)
jump to
M
routes/template.go
→
routes/template.go
@@ -59,7 +59,7 @@
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