additional error check

This commit is contained in:
Motiejus Jakštys 2021-08-19 16:32:22 +03:00
parent f1566184cf
commit 34a4ebfeaa
2 changed files with 4 additions and 1 deletions

View File

@ -31,7 +31,7 @@ func main() {
c := &command{flattener: rootfs.Flatten, Stdout: os.Stdout} c := &command{flattener: rootfs.Flatten, Stdout: os.Stdout}
if err := c.execute(os.Args[1], os.Args[2]); err != nil { if err := c.execute(os.Args[1], os.Args[2]); err != nil {
fmt.Printf("Error: %v", err) fmt.Printf("Error: %v\n", err)
os.Exit(1) os.Exit(1)
} }
os.Exit(0) os.Exit(0)

View File

@ -52,6 +52,9 @@ func Flatten(rd io.ReadSeeker, w io.Writer) (_err error) {
if err == io.EOF { if err == io.EOF {
break break
} }
if err != nil {
return err
}
if hdr.Typeflag != tar.TypeReg { if hdr.Typeflag != tar.TypeReg {
continue continue
} }