Skip to content

Commit

Permalink
sys/syz-extract: provide readable error on missing input file
Browse files Browse the repository at this point in the history
Currently syz-extract crashes with nil deref panic if
it is executed manually and is gives an absent file name.
Output a readable error.
  • Loading branch information
dvyukov committed Apr 19, 2018
1 parent e5453dd commit 500489e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sys/syz-extract/extract.go
Expand Up @@ -256,6 +256,9 @@ func processArch(OS OS, arch *Arch) (map[string]*compiler.ConstInfo, error) {
func processFile(OS OS, arch *Arch, file *File) (map[string]uint64, map[string]bool, error) {
inname := filepath.Join("sys", arch.target.OS, file.name)
outname := strings.TrimSuffix(inname, ".txt") + "_" + arch.target.Arch + ".const"
if file.info == nil {
return nil, nil, fmt.Errorf("input file %v is missing", inname)
}
if len(file.info.Consts) == 0 {
os.Remove(outname)
return nil, nil, nil
Expand Down

0 comments on commit 500489e

Please sign in to comment.