From d15dc439a7c067a0124bafaeaeb421a4b159fac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Gro=C3=9F?= Date: Sun, 17 Jan 2016 20:18:18 +0100 Subject: [PATCH] Improved auxv entry parsing --- pwndbg/auxv.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/pwndbg/auxv.py b/pwndbg/auxv.py index e5f20a5e4..84d6c8ae0 100644 --- a/pwndbg/auxv.py +++ b/pwndbg/auxv.py @@ -1,4 +1,5 @@ import os +import re import sys import gdb @@ -106,19 +107,14 @@ def use_info_auxv(): auxv = AUXV() for line in lines: - tokens = line.split() - const = int(tokens[0]) + match = re.match('([0-9]+) .* (0x[0-9a-f]+|[0-9]+)', line) + if not match: + print("Warning: Skipping auxv entry '{}'".format(line)) + continue - # GDB will attempt to read strings for us, we dont want this - if '"' in tokens[-1]: tokens.pop(-1) - - # If there' a memory read error, there will be some trash at the end. - # 31 AT_EXECFN File name of executable 0xffffdfef - # So we just need to strip the trailing '>' - tokens[-1] = tokens[-1].rstrip('>') - - value = eval(tokens[-1]) + const, value = int(match.group(1)), int(match.group(2), 0) auxv.set(const, value) + return auxv