From 0bb4a32ea18aa343aad76a3ec7808565e39ac624 Mon Sep 17 00:00:00 2001 From: Zach Riggle Date: Mon, 9 Mar 2015 21:56:57 -0700 Subject: [PATCH] Remove loops and excessively long chains --- pwndbg/chain.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pwndbg/chain.py b/pwndbg/chain.py index 291b32eee..a6785cfb1 100644 --- a/pwndbg/chain.py +++ b/pwndbg/chain.py @@ -15,6 +15,10 @@ def get(address, limit=5): """ result = [] for i in range(limit): + # Don't follow cycles, except to stop at the second occurrence. + if result.count(address) >= 2: + break + result.append(address) try: address = int(pwndbg.memory.poi(pwndbg.types.ppvoid, address)) @@ -36,9 +40,12 @@ def format(value): # Otherwise, the last element in the chain is the non-pointer value. # We want to enhance the last pointer value. - else: + elif len(chain) < 6: enhanced = pwndbg.enhance.enhance(chain[-2]) + else: + enhanced = '...' + # Colorize the rest rest = [] for link in chain[:-1]: