Skip to content

Commit d2524e8

Browse files
committed
don't process long lines
1 parent 29bbd2e commit d2524e8

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

revgrep.go

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -281,24 +281,12 @@ func (c Checker) linesChanged() map[string][]pos {
281281

282282
scanner := bufio.NewReader(c.Patch)
283283
var scanErr error
284-
Loop:
285284
for {
286285
lineB, isPrefix, err := scanner.ReadLine()
287286
if isPrefix {
288-
// If a single line overflowed the buffer, keep building it up. This
289-
// leaves the possibility of a DOS attack by a user creating a git commit
290-
// with a line so large it OOMs the process calling golangci-lint.
291-
for {
292-
lineB2, isPrefix2, err2 := scanner.ReadLine()
293-
if err2 != nil {
294-
scanErr = err2
295-
break Loop
296-
}
297-
lineB = append(lineB, lineB2...)
298-
if isPrefix2 {
299-
continue
300-
}
301-
}
287+
// If a single line overflowed the buffer, don't bother processing it as
288+
// it's likey part of a file and not relevant to the patch.
289+
continue
302290
}
303291
if err != nil {
304292
scanErr = err

0 commit comments

Comments
 (0)