From 1811b9547134a707c81cd3bf569e9a48ff794596 Mon Sep 17 00:00:00 2001 From: Nikita Abdullin <0xABD@users.noreply.github.com> Date: Wed, 23 Dec 2015 17:17:32 +0100 Subject: [PATCH 1/2] Fix the manpage parser regexp Modify the manpage parser regexp to select only the first occurrence of the "TYPE FUNCTION(TYPE ARG, ...)", including multiline function prototypes. --- src/frida/tracer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frida/tracer.py b/src/frida/tracer.py index f6222b8..0fcf45c 100644 --- a/src/frida/tracer.py +++ b/src/frida/tracer.py @@ -1283,7 +1283,7 @@ class Repository(object): man_argv.extend(["-E", "UTF-8"]) man_argv.extend(["-P", "col -b", "2", function.name]) output = subprocess.check_output(man_argv, stderr=devnull) - match = re.search(r"^SYNOPSIS(?:.|\n)*?((?:^.+$\n)* {5}" + function.name + r"\(.*\n(^.+$\n)*)(?:.|\n)*^DESCRIPTION", output.decode('UTF-8', errors='replace'), re.MULTILINE) + match = re.search(r"^SYNOPSIS(?:.|\n)*?((?:^.+$\n)* {5}\w+ " + function.name + r"\((?:.+\,\s*?$\n)*?(?:.+\;$\n))(?:.|\n)*^DESCRIPTION", output.decode('UTF-8', errors='replace'), re.MULTILINE) if match: decl = match.group(1) for argm in re.finditer(r"([^* ]*)\s*(,|\))", decl): From 11280383922ad7ba868d2b6f5d77db3e0f943cb6 Mon Sep 17 00:00:00 2001 From: Nikita Abdullin <0xABD@users.noreply.github.com> Date: Wed, 23 Dec 2015 17:29:16 +0100 Subject: [PATCH 2/2] Fix manpage parser regexp for "*funcname" Also include functions like *mmap whose return type is a pointer. --- src/frida/tracer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frida/tracer.py b/src/frida/tracer.py index 0fcf45c..67e93ae 100644 --- a/src/frida/tracer.py +++ b/src/frida/tracer.py @@ -1283,7 +1283,7 @@ class Repository(object): man_argv.extend(["-E", "UTF-8"]) man_argv.extend(["-P", "col -b", "2", function.name]) output = subprocess.check_output(man_argv, stderr=devnull) - match = re.search(r"^SYNOPSIS(?:.|\n)*?((?:^.+$\n)* {5}\w+ " + function.name + r"\((?:.+\,\s*?$\n)*?(?:.+\;$\n))(?:.|\n)*^DESCRIPTION", output.decode('UTF-8', errors='replace'), re.MULTILINE) + match = re.search(r"^SYNOPSIS(?:.|\n)*?((?:^.+$\n)* {5}\w+ \**?" + function.name + r"\((?:.+\,\s*?$\n)*?(?:.+\;$\n))(?:.|\n)*^DESCRIPTION", output.decode('UTF-8', errors='replace'), re.MULTILINE) if match: decl = match.group(1) for argm in re.finditer(r"([^* ]*)\s*(,|\))", decl):