Skip to content

Commit

Permalink
fix el-torito boot image checksum/etc
Browse files Browse the repository at this point in the history
  • Loading branch information
MagicalTux committed Apr 11, 2020
1 parent d1afa6a commit fcc8500
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 5 additions & 3 deletions bootcatalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func encodeBootCatalogs(e []*BootCatalogEntry) ([]byte, error) {
}

// load_rba
binary.Write(buf, binary.LittleEndian, b.file.meta().targetSector) // 4 bytes
binary.Write(buf, binary.LittleEndian, uint32(b.file.meta().targetSector)) // 4 bytes

buf.Write(make([]byte, 20)) // "Vendor unique selection criteria."

Expand All @@ -81,10 +81,12 @@ func doBootCatalogChecksum(b []byte) []byte {
var v uint16

for i := 0; i < len(b); i += 2 {
v += uint16((b[i] << 8) | b[i+1])
v -= binary.LittleEndian.Uint16(b[i : i+2])
}

return []byte{byte(v >> 8), byte(v & 0xff)}
res := make([]byte, 2)
binary.LittleEndian.PutUint16(res, v)
return res
}

func doElToritoTableChecksum(in []byte) (r uint32) {
Expand Down
3 changes: 3 additions & 0 deletions image_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ func (iw *ImageWriter) getDir(directoryPath string) (*itemDir, error) {
dp := strings.Split(directoryPath, "/")
pos := iw.root
for _, seg := range dp {
if seg == "" {
continue
}
if v, ok := pos.children[seg]; ok {
if rV, ok := v.(*itemDir); ok {
pos = rV
Expand Down

0 comments on commit fcc8500

Please # to comment.