[#951] adm: Check for error when reading contracts from archive
All checks were successful
Vulncheck / Vulncheck (pull_request) Successful in 3m17s
DCO action / DCO (pull_request) Successful in 3m3s
Build / Build Components (1.21) (pull_request) Successful in 4m28s
Build / Build Components (1.22) (pull_request) Successful in 4m29s
Pre-commit hooks / Pre-commit (pull_request) Successful in 4m46s
Tests and linters / gopls check (pull_request) Successful in 6m41s
Tests and linters / Lint (pull_request) Successful in 7m54s
Tests and linters / Staticcheck (pull_request) Successful in 7m32s
Tests and linters / Tests (1.21) (pull_request) Successful in 9m26s
Tests and linters / Tests with -race (pull_request) Successful in 9m26s
Tests and linters / Tests (1.22) (pull_request) Successful in 9m30s

Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
Anton Nikiforov 2024-06-06 15:25:51 +03:00
parent 8fcd0f8f8d
commit efcebdf009

View file

@ -122,11 +122,11 @@ func readContractsFromArchive(file io.Reader, names []string) (map[string]*Contr
} }
r := tar.NewReader(gr) r := tar.NewReader(gr)
for h, err := r.Next(); ; h, err = r.Next() { var h *tar.Header
if err != nil { for h, err = r.Next(); err == nil && h != nil; h, err = r.Next() {
break if h.Typeflag != tar.TypeReg {
continue
} }
dir, _ := filepath.Split(h.Name) dir, _ := filepath.Split(h.Name)
ctrName := filepath.Base(dir) ctrName := filepath.Base(dir)
@ -149,6 +149,9 @@ func readContractsFromArchive(file io.Reader, names []string) (map[string]*Contr
} }
m[ctrName] = cs m[ctrName] = cs
} }
if err != nil && err != io.EOF {
return nil, fmt.Errorf("can't read contracts from archive: %w", err)
}
for ctrName, cs := range m { for ctrName, cs := range m {
if cs.RawNEF == nil { if cs.RawNEF == nil {