From 991cf22504d78fab1ca0d39b4ad49fde06ef257c Mon Sep 17 00:00:00 2001 From: Vladislav Rassokhin Date: Tue, 16 Jul 2019 16:01:35 +0300 Subject: [PATCH] Prevent endless reading of closed file in vmware plugin --- builder/vmware/common/driver_parser.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/builder/vmware/common/driver_parser.go b/builder/vmware/common/driver_parser.go index fc54b8221..b464ffbc1 100644 --- a/builder/vmware/common/driver_parser.go +++ b/builder/vmware/common/driver_parser.go @@ -2,7 +2,6 @@ package common import ( "fmt" - "io" "log" "math" "net" @@ -1962,7 +1961,9 @@ func consumeFile(fd *os.File) (chan byte, sentinelSignaller) { b := make([]byte, 1) for { _, err := fd.Read(b) - if err == io.EOF { + if err != nil { + // In case of any error we must stop + // ErrClosed may appear since file is closed and this goroutine still left running break } fromfile <- b[0]