vmt / udis86

Disassembler Library for x86 and x86-64
http://udis86.sourceforge.net
BSD 2-Clause "Simplified" License
1.02k stars 299 forks source link

Compatibility with ud_opcode.py and Python 3.5 #120

Open Rudedog9d opened 7 years ago

Rudedog9d commented 7 years ago

There is a TypeError Raised by the following code in ud_opcode.py when run in Python 3.5: TypeError: %x format: an integer is required, not float

    for k, e in entries:
        if isinstance(e, UdOpcodeTable):
            self.log("%s    |-<%02x> %s" % (indent, k, e))
            printWalk(e, indent + "    |")
        elif isinstance(e, UdInsnDef):
            self.log("%s    |-<%02x> %s" % (indent, k, e))

Purposed fix: Typecast the float k to an integer. (self.log("%s |-<%02x> %s" % (indent, int(k), e)))

Would this cause problems? The built in function k.hex() could be used but this produces a string, which would then not be format-able.

woodruffw commented 1 year ago

This is also preventing mishegos, which fuzzes this project, from upgrading its environment: https://github.com/trailofbits/mishegos/pull/1606#discussion_r1041222217

martindorey commented 1 year ago

A second pull request that fixes this, in what's imo a less elegant way, is at https://github.com/vmt/udis86/pull/132/commits/9c11d83f848709b8f5414d17f8f909a4d77aa9c3. A third pull request that fixes this is in https://github.com/vmt/udis86/pull/139. That, imo, is the most elegant of the three, getting rid of the unnecessarily floating point numbers at the root of the issue. I confirm it's correct and complete.