[OE-core] [PATCH 5/5] lib/oe/package.py: is_elf: Make it less prone to false positives

Olof Johansson olof.johansson at axis.com
Fri Dec 1 15:50:24 UTC 2017


Avoid matching substrings that are picked up from paths, for instance.
Do this by anchoring the tokens we look for (e.g "executable" or "not
stripped") with whitespace and punctuation.

Submitted with this patch series is a change that adds the use of
--brief to file. This removes the path prefix to the output, but the
path can still be included in shebang lines (which file will report as
something like "a /foo/bar/baz.py script").

Signed-off-by: Olof Johansson <olofjn at axis.com>
---
 meta/lib/oe/package.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/meta/lib/oe/package.py b/meta/lib/oe/package.py
index 976d2ef36c..2bd771cfc5 100644
--- a/meta/lib/oe/package.py
+++ b/meta/lib/oe/package.py
@@ -84,17 +84,17 @@ def is_elf(path, on_error=_is_elf_error):
         error_cb('"file %s" failed')
         return
 
-    if not "ELF" in result:
+    if not result.startswith("ELF "):
         return 0
 
     exec_type = 1
-    if "not stripped" not in result:
+    if ", not stripped" not in result:
         exec_type |= 2
-    if "executable" in result:
+    if " executable, " in result:
         exec_type |= 4
-    if "shared" in result:
+    if " shared object, " in result:
         exec_type |= 8
-    if "relocatable" in result and is_kernel_module(path):
+    if "relocatable, " in result and is_kernel_module(path):
         exec_type |= 16
     return exec_type
 
-- 
2.11.0




More information about the Openembedded-core mailing list