Skip to content

Commit

Permalink
Merge pull request #211 from max-gotlib/ElTorito-Boot-Image-Size-Fix
Browse files Browse the repository at this point in the history
Fix for truncated boot image size recorded with ElTorito boot catalog and boot info table.
  • Loading branch information
deitch authored Apr 30, 2024
2 parents d67c42d + fc7fcfd commit 7e52208
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions filesystem/iso9660/eltorito.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ type ElToritoEntry struct {
SystemType mbr.Type
// LoadSize how many blocks of BootFile to load, equivalent to genisoimage option `-boot-load-size`
LoadSize uint16
size uint16
size uint32
location uint32
}

Expand Down Expand Up @@ -127,7 +127,7 @@ func (e *ElToritoEntry) headerBytes(last bool, entries uint16) []byte {
func (e *ElToritoEntry) entryBytes() []byte {
blocks := e.LoadSize
if blocks == 0 {
blocks = e.size / 512
blocks = uint16(e.size / 512)
if e.size%512 > 1 {
blocks++
}
Expand All @@ -153,7 +153,7 @@ func (e *ElToritoEntry) generateBootTable(pvdSector uint32, p string) ([]byte, e
b := make([]byte, 56)
binary.LittleEndian.PutUint32(b[0:4], pvdSector)
binary.LittleEndian.PutUint32(b[4:8], e.location)
binary.LittleEndian.PutUint32(b[8:12], uint32(e.size))
binary.LittleEndian.PutUint32(b[8:12], e.size)
// Checksum - simply add up all 32-bit words beginning at byte position 64
f, err := os.Open(p)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion filesystem/iso9660/finalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ func (fs *FileSystem) Finalize(options FinalizeOptions) error {
}
}
// save the child so we can add location late
e.size = uint16(child.size)
e.size = uint32(child.size)
child.elToritoEntry = e
}
}
Expand Down

0 comments on commit 7e52208

Please sign in to comment.