forked from pool/rpmlint
Dirk Mueller
68c088a14f
OBS-URL: https://build.opensuse.org/package/show/devel:openSUSE:Factory:rpmlint/rpmlint?expand=0&rev=363
107 lines
3.7 KiB
Diff
107 lines
3.7 KiB
Diff
From 4d995b87763076cc2aca25b7836e106708bd926f Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>
|
|
Date: Fri, 23 Oct 2015 23:43:16 +0200
|
|
Subject: [PATCH] Skip checks for problematic function calls if common prefix
|
|
does not match
|
|
|
|
The regexes have a common prefix. If the prefix does not match, none of
|
|
the regexes will match, continue with the next line.
|
|
---
|
|
BinariesCheck.py | 53 ++++++++++++++++++++++++++++++++---------------------
|
|
1 file changed, 32 insertions(+), 21 deletions(-)
|
|
|
|
diff --git a/BinariesCheck.py b/BinariesCheck.py
|
|
index d2ed87a..52a7aae 100644
|
|
--- a/BinariesCheck.py
|
|
+++ b/BinariesCheck.py
|
|
@@ -28,14 +28,14 @@ DEFAULT_SYSTEM_LIB_PATHS = (
|
|
def create_regexp_call(call):
|
|
if type(call) == type([]):
|
|
call = '(?:' + '|'.join(call) + ')'
|
|
- r = "\s+FUNC\s+.*?\s+(%s(?:@GLIBC\S+)?)(?:\s|$)" % call
|
|
+ r = ".*?\s+(%s(?:@GLIBC\S+)?)(?:\s|$)" % call
|
|
return re.compile(r)
|
|
|
|
|
|
def create_nonlibc_regexp_call(call):
|
|
if type(call) == type([]):
|
|
call = '(?:' + '|'.join(call) + ')'
|
|
- r = "\s+FUNC\s+.*?\s+UND\s+(%s)\s?.*$" % call
|
|
+ r = ".*?\s+UND\s+(%s)\s?.*$" % call
|
|
return re.compile(r)
|
|
|
|
|
|
@@ -51,6 +51,7 @@ class BinaryInfo:
|
|
stack_exec_regex = re.compile('^..E$')
|
|
undef_regex = re.compile('^undefined symbol:\s+(\S+)')
|
|
unused_regex = re.compile('^\s+(\S+)')
|
|
+ call_regex = re.compile('\s0\s+FUNC\s+(.*)')
|
|
exit_call_regex = create_regexp_call('_?exit')
|
|
fork_call_regex = create_regexp_call('fork')
|
|
# regexp for setgid setegid setresgid set(?:res|e)?gid
|
|
@@ -103,25 +104,8 @@ class BinaryInfo:
|
|
cmd.append(path)
|
|
res = Pkg.getstatusoutput(cmd)
|
|
if not res[0]:
|
|
- for l in res[1].splitlines():
|
|
- if BinaryInfo.mktemp_call_regex.search(l):
|
|
- self.mktemp = True
|
|
-
|
|
- if BinaryInfo.setgid_call_regex.search(l):
|
|
- self.setgid = True
|
|
-
|
|
- if BinaryInfo.setuid_call_regex.search(l):
|
|
- self.setuid = True
|
|
-
|
|
- if BinaryInfo.setgroups_call_regex.search(l):
|
|
- self.setgroups = True
|
|
-
|
|
- if BinaryInfo.chdir_call_regex.search(l):
|
|
- self.chdir = True
|
|
-
|
|
- if BinaryInfo.chroot_call_regex.search(l):
|
|
- self.chroot = True
|
|
-
|
|
+ lines = res[1].splitlines()
|
|
+ for l in lines:
|
|
r = BinaryInfo.needed_regex.search(l)
|
|
if r:
|
|
self.needed.append(r.group(1))
|
|
@@ -154,6 +138,33 @@ class BinaryInfo:
|
|
self.exec_stack = True
|
|
continue
|
|
|
|
+ if l.startswith("Symbol table"):
|
|
+ break
|
|
+
|
|
+ for l in lines:
|
|
+ r = BinaryInfo.call_regex.search(l)
|
|
+ if not r:
|
|
+ continue
|
|
+ l = r.group(1)
|
|
+
|
|
+ if BinaryInfo.mktemp_call_regex.search(l):
|
|
+ self.mktemp = True
|
|
+
|
|
+ if BinaryInfo.setgid_call_regex.search(l):
|
|
+ self.setgid = True
|
|
+
|
|
+ if BinaryInfo.setuid_call_regex.search(l):
|
|
+ self.setuid = True
|
|
+
|
|
+ if BinaryInfo.setgroups_call_regex.search(l):
|
|
+ self.setgroups = True
|
|
+
|
|
+ if BinaryInfo.chdir_call_regex.search(l):
|
|
+ self.chdir = True
|
|
+
|
|
+ if BinaryInfo.chroot_call_regex.search(l):
|
|
+ self.chroot = True
|
|
+
|
|
if BinaryInfo.forbidden_functions:
|
|
for r_name, func in BinaryInfo.forbidden_functions.items():
|
|
ret = func['f_regex'].search(l)
|
|
--
|
|
2.7.0
|
|
|