Skip to content

Commit

Permalink
Merge pull request #552 from rgooch/master
Browse files Browse the repository at this point in the history
Bugfixes: panic in objectserver and image-unpacker makes unbootable images.
  • Loading branch information
rgooch committed Jan 24, 2019
2 parents 6d4413c + 7832916 commit 2b7173b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 0 additions & 1 deletion lib/filesystem/util/writeRaw.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ func makeBootable(fs *filesystem.FileSystem,
if bootInfo, err := getBootInfo(fs, rootLabel, kernelOptions); err != nil {
return err
} else {
bootInfo.KernelOptions = kernelOptions
return bootInfo.installBootloader(deviceName, rootDir, rootLabel,
doChroot, logger)
}
Expand Down
13 changes: 8 additions & 5 deletions lib/objectcache/filename.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func filenameToHash(fileName string) (hash.Hash, error) {
var hash hash.Hash
var hashVal hash.Hash
var prev_nibble byte = 16
index := 0
for _, char := range fileName {
Expand All @@ -20,16 +20,19 @@ func filenameToHash(fileName string) (hash.Hash, error) {
continue // Ignore everything else. Treat them as separators.
}
if prev_nibble < 16 {
hash[index] = nibble | prev_nibble<<4
if index >= len(hashVal) {
return hashVal, fmt.Errorf("filename too long: %s", fileName)
}
hashVal[index] = nibble | prev_nibble<<4
index++
prev_nibble = 16
} else {
prev_nibble = nibble
}
}
return hash, nil
return hashVal, nil
}

func hashToFilename(hash hash.Hash) string {
return fmt.Sprintf("%02x/%02x/%0x", hash[0], hash[1], hash[2:])
func hashToFilename(hashVal hash.Hash) string {
return fmt.Sprintf("%02x/%02x/%0x", hashVal[0], hashVal[1], hashVal[2:])
}

0 comments on commit 2b7173b

Please sign in to comment.