From 317792433e4e961441f772c6bd22d63873a8c986 Mon Sep 17 00:00:00 2001 From: DmitriyLewen <91113035+DmitriyLewen@users.noreply.github.com> Date: Mon, 18 Mar 2024 15:42:54 +0600 Subject: [PATCH] fix: increase the default buffer size for scanning dpkg status files by 2 times (#6298) --- pkg/fanal/analyzer/pkg/dpkg/scanner.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/fanal/analyzer/pkg/dpkg/scanner.go b/pkg/fanal/analyzer/pkg/dpkg/scanner.go index de5c39a6a174..2e38f06b0cf7 100644 --- a/pkg/fanal/analyzer/pkg/dpkg/scanner.go +++ b/pkg/fanal/analyzer/pkg/dpkg/scanner.go @@ -15,6 +15,11 @@ type dpkgScanner struct { // NewScanner returns a new scanner that splits on empty lines. func NewScanner(r io.Reader) *dpkgScanner { s := bufio.NewScanner(r) + // Package data may exceed default buffer size + // Increase the buffer default size by 2 times + buf := make([]byte, 0, 128*1024) + s.Buffer(buf, 128*1024) + s.Split(emptyLineSplit) return &dpkgScanner{Scanner: s} }