Fix chroot untar for zero padded archive from slow reader

Signed-off-by: Lewis Marshall <lewis@lmars.net>
This commit is contained in:
Lewis Marshall 2014-12-06 02:30:03 +00:00 committed by Tibor Vass
parent 1036313f03
commit a8124280d2
2 changed files with 46 additions and 0 deletions

View file

@ -6,6 +6,7 @@ import (
"flag"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"runtime"
@ -38,6 +39,10 @@ func untar() {
if err := archive.Unpack(os.Stdin, "/", options); err != nil {
fatal(err)
}
// fully consume stdin in case it is zero padded
if _, err := ioutil.ReadAll(os.Stdin); err != nil {
fatal(err)
}
os.Exit(0)
}