From adf31064aa94a982c2d2b32c456111d3e09b3bbb Mon Sep 17 00:00:00 2001 From: alexet Date: Mon, 11 Oct 2021 14:31:52 +0100 Subject: [PATCH] Avoid reading non-regular files. --- processor/file.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/processor/file.go b/processor/file.go index c0864d026..fa586b841 100644 --- a/processor/file.go +++ b/processor/file.go @@ -234,6 +234,15 @@ func newFileJob(path, name string, fileInfo os.FileInfo) *FileJob { fileInfo, _ = os.Lstat(symPath) } + // Skip non-regular files. They are unlikely to be code and may hang if we + // try and read them. + if !fileInfo.Mode().IsRegular() { + if Verbose { + printWarn(fmt.Sprintf("skipping non-regular file: %s", path)) + } + return nil + } + language, extension := DetectLanguage(name) if len(language) != 0 {