@@ -68,10 +68,10 @@ func extract7z(xFile *XFile) (int64, []string, []string, error) {
6868 if err != nil {
6969 lastFile := xFile .FilePath
7070 /* // https://github.com/bodgit/sevenzip/issues/54
71- // We can probably never get the file with the error.
72- if volumes := sevenZip.Volumes(); len(volumes) > 0 {
73- lastFile = volumes[len(volumes)-1]
74- } */
71+ // We can probably never get the file with the error.
72+ if volumes := sevenZip.Volumes(); len(volumes) > 0 {
73+ lastFile = volumes[len(volumes)-1]
74+ } */
7575 return size , files , sevenZip .Volumes (), fmt .Errorf ("%s: %w" , lastFile , err )
7676 }
7777
@@ -84,7 +84,8 @@ func extract7z(xFile *XFile) (int64, []string, []string, error) {
8484
8585func (x * XFile ) un7zip (zipFile * sevenzip.File ) (int64 , error ) { //nolint:dupl
8686 wfile := x .clean (zipFile .Name )
87- if ! strings .HasPrefix (wfile , x .OutputDir ) {
87+ outputDir := filepath .Clean (x .OutputDir )
88+ if ! strings .HasPrefix (wfile , outputDir ) {
8889 // The file being written is trying to write outside of our base path. Malicious archive?
8990 return 0 , fmt .Errorf ("%s: %w: %s (from: %s)" , zipFile .FileInfo ().Name (), ErrInvalidPath , wfile , zipFile .Name )
9091 }
0 commit comments