Skip to content

Commit

Permalink
fix(windows): crash on out of bounds for root path cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: manifestori <ori@manifestcyber.com>
  • Loading branch information
manifestori committed May 20, 2024
1 parent aa7bfad commit 0e46c1c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion builder/build_package.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"path/filepath"
"regexp"
"runtime"
"strings"

"github.com/spdx/tools-golang/spdx"
"github.com/spdx/tools-golang/spdx/v2/common"
Expand Down Expand Up @@ -42,7 +43,11 @@ func BuildPackageSection(packageName string, dirRoot string, pathsIgnore []strin
for _, fp := range filepaths {
newFilePatch := ""
if osType == "windows" {
newFilePatch = filepath.FromSlash("." + fp[dirRootLen:])
if strings.HasPrefix(fp, dirRoot) {
newFilePatch = filepath.FromSlash("." + fp[dirRootLen:])
} else {
newFilePatch = filepath.FromSlash("." + fp)
}
} else {
newFilePatch = filepath.FromSlash("./" + fp)
}
Expand Down

0 comments on commit 0e46c1c

Please sign in to comment.