Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion filesystem/iso9660/finalize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,25 @@ var (

// test creating an iso with el torito boot
func TestFinalizeElTorito(t *testing.T) {
finalizeElTorito(t, "")
dir, err := os.MkdirTemp("", "workspace")
if err != nil {
t.Fatalf("Failed to create temp dir: %v", err)
}
finalizeElTorito(t, dir)
}

func TestFinalizeElToritoWithInaccurateTmpDir(t *testing.T) {
finalizeElTorito(t, "")
dir, err := os.MkdirTemp("/tmp//", "workspace")
if err != nil {
t.Fatalf("Failed to create temp dir: %v", err)
}
finalizeElTorito(t, dir)
}

//nolint:thelper // this is not a helper function
func finalizeElTorito(t *testing.T, workspace string) {
blocksize := int64(2048)
f, err := os.CreateTemp("", "iso_finalize_test")
defer os.Remove(f.Name())
Expand All @@ -31,7 +50,7 @@ func TestFinalizeElTorito(t *testing.T) {
}

b := file.New(f, false)
fs, err := iso9660.Create(b, 0, 0, blocksize, "")
fs, err := iso9660.Create(b, 0, 0, blocksize, workspace)
if err != nil {
t.Fatalf("Failed to iso9660.Create: %v", err)
}
Expand Down
4 changes: 4 additions & 0 deletions filesystem/iso9660/iso9660.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path"
"path/filepath"

"github.com/diskfs/go-diskfs/backend"
"github.com/diskfs/go-diskfs/filesystem"
Expand Down Expand Up @@ -97,6 +98,9 @@ func Create(b backend.Storage, size, start, blocksize int64, workspace string) (
}
}

// sometimes, at least on macos, extra separators in path can cause panic
workdir = filepath.Clean(workdir)

// create root directory
// there is nothing in there
return &FileSystem{
Expand Down