Skip to content

Commit

Permalink
verify overrides are extracted in bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
nothub committed Feb 2, 2023
1 parent 5ce20fb commit 4b1770f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion modrinth/mrpack/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package mrpack
import (
"archive/zip"
"fmt"
"github.com/nothub/mrpack-install/util"
"io"
"log"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -37,8 +39,15 @@ func ExtractOverrides(zipFile string, target string) error {
}

targetPath := path.Join(target, filePath)
ok, err := util.PathIsSubpath(targetPath, target)
if err != nil {
log.Println(err.Error())
}
if err != nil || !ok {
log.Fatalln("File path is not safe: " + targetPath)
}

err := os.MkdirAll(filepath.Dir(targetPath), 0755)
err = os.MkdirAll(filepath.Dir(targetPath), 0755)
if err != nil {
return err
}
Expand Down

0 comments on commit 4b1770f

Please sign in to comment.