[elflib] Fail if the input file is not a directory
All input arguments are expected to be .build-id directories.
This previously broke release builders.
Bug: IN-1132 #done
TEST:locally on a Fuchsia checkout
Change-Id: If5f222de1bf9301522772366b6db27b34d9eda1a
diff --git a/elflib/elflib.go b/elflib/elflib.go
index 202c047..bea4142 100644
--- a/elflib/elflib.go
+++ b/elflib/elflib.go
@@ -205,6 +205,13 @@
// deadbeef.debug
// deadmeat.debug
func WalkBuildIDDir(dirpath string) ([]BinaryFileRef, error) {
+ info, err := os.Stat(dirpath)
+ if err != nil {
+ return nil, fmt.Errorf("failed to stat %q: %v", dirpath, err)
+ }
+ if !info.IsDir() {
+ return nil, fmt.Errorf("%q is not a directory", dirpath)
+ }
var refs []BinaryFileRef
if err := filepath.Walk(dirpath, func(path string, info os.FileInfo, err error) error {
if err != nil {