Skip to contentSkip to conversation

lib/oe/qa: check that a path is a file before opening it

PATCH New Ross Burton 1 participant 1 message Feb 8, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/oe/qa: check that a path is a file before opening it

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.

---
 meta/lib/oe/qa.py | 4 ++++
 1 file changed, 4 insertions(+)
meta/lib/oe/qa.py +4 -0
index d5cdaa0..4cb5b98 100644
@@ -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)
 
Signature · 1 line
2.7.0