Git Product home page Git Product logo

bfdpie's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

bfdpie's Issues

TypeError: invalid parameter(s) for large vma

It looks like there is an issue with handling vmas > INT_MAX due to the arguments used with PyArg.
This example can reproduce the problem on my 64-bit machine with gcc 7.30, python 3.6.5, and bfdpie 0.1.13 from pypi:

import bfdpie

bfdpie.Binary().disassemble_simple(b"\x90", bfdpie.ARCH_X86_64, 0x7fffffff)
bfdpie.Binary().disassemble_simple(b"\x90", bfdpie.ARCH_X86_64, 0x80000000)

which gives the following output:

nop
Traceback (most recent call last):
  File "./bfdtest.py", line 6, in <module>
    bfdpie.Binary().disassemble_simple(b"\x90", bfdpie.ARCH_X86_64, 0x80000000)
  File "/usr/local/lib/python3.6/dist-packages/bfdpie/bfdpie.py", line 336, in disassemble_simple
    for i in self.disassemble(data, arch, vma):
  File "/usr/local/lib/python3.6/dist-packages/bfdpie/bfdpie.py", line 318, in disassemble
    ops = _bfd.disassemble_bytes(self._ptr, arch_id, data, vma)
TypeError: Invalid parameter(s)

I believe this is due to this code in the function pybfd_disassemble_bytes in bfdpie.c:

// ...
size_t vma;
if(PyArg_ParseTuple(args, "nis#i", &abfd, &arch_num, &data, &data_len, &vma))
{
   // ...
}
else
{
  PyErr_SetString(PyExc_TypeError, "Invalid parameter(s)");
}
// ...

Where according to this page, the i format parses the value assigned to vma as an int rather than as a size_t. This issue can be fixed by changing the type of vma to unsigned long long and using the format specifier K.

Memory leak

Hi,

There is a memory leak in this module, but I don't know exactly where.

I've made a script that would use just two attributes of the library:

  1. The constructor
  2. The "symbols" instance attribute

After inspecting thousands of binaries, python process was at 10GB of allocated memory.

I'm running Python 3.6.1 (64-bit) on CentOS 7.1.1503 and using the latest available version on pypi. Compiler is gcc 4.8.3.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.