rapid7/metasploit-framework — pull request #1835 by bannedit (2013-05-16 02:14:27+00:00)
Title: Fix a backwards disasm bug which stomps on the depth option

This fixes a bug where the user specifies a depth as the number of bytes to backwards disassemble but rop.rb only gives back the first successful disassembly.

The problem is mainly caused by the loop which iterates through the depth value from 0..value. This means the very first good backwards disassembly is the only one used. This results in 2 instruction gadgets rather than the expected multiple instruction gadgets. Reversing the iterator using value..0 gives the first good multiple instruction disassembly instead. Thus fixing the problem.