[OE-core] [PATCH] lib/oe/qa: check that a path is a file before opening it

Ross Burton ross.burton at intel.com
Mon Feb 8 20:36:43 UTC 2016


Check that a filename points to a normal file before attempting to open it, as
if the file turns out to be something more exotic like a FIFO it could hang
forever.

Signed-off-by: Ross Burton <ross.burton at intel.com>
---
 meta/lib/oe/qa.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/meta/lib/oe/qa.py b/meta/lib/oe/qa.py
index d5cdaa0..4cb5b98 100644
--- a/meta/lib/oe/qa.py
+++ b/meta/lib/oe/qa.py
@@ -31,6 +31,10 @@ class ELFFile:
         self.objdump_output = {}
 
     def open(self):
+        import os.path
+        if not os.path.isfile(self.name):
+            raise Exception("File is not a normal file")
+
         self.file = file(self.name, "r")
         self.data = self.file.read(ELFFile.EI_NIDENT+4)
 
-- 
2.7.0




More information about the Openembedded-core mailing list