Open GoogleCodeExporter opened 9 years ago
Debugging the code I discovered that segfault comes from similatiry.c:301
inside entropy(). When segfault occurred size_orig was too long compared. I
don't now what entropy exactly does, but in other times that it was called
size_orig was always equal to strlen(c_orig) so I force size_orig to be equal
to c_orig inside entropy. Besides i could detect that this problem was caused
by this instruction "PyArg_ParseTuple( args, "s#", &input, &input_size );" at
elsign.cc:1262 what seems to parse the tuple wrong, resulting in a wrong input
size. I don't now what is the real impact of my changes but, doing what I've
described androsign could detect malwares that were in Androguard database.
Original comment by oshiro.h...@gmail.com
on 18 Mar 2015 at 6:10
In my case, i found that the problem was in uninitialized local variables
(which is my opinion is very bad taste) here:
PyObject *entropy(PyObject *self, PyObject* args)
{
char *input; size_t input_size;
// FIX: char *input = NULL; size_t input_size = 0;
int ok = PyArg_ParseTuple( args, "s#", &input, &input_size );
if(!ok) return PyInt_FromLong(-1);
double value = entropy( input, input_size );
return PyFloat_FromDouble( value );
}
So, initializing them to NULL and 0 fixed the problem, seems like
PyArg_ParseTuple doesn't allocate memory if it got a non NULL pointer. Hope it
helps you, it helped to me :)
Original comment by krasner....@gmail.com
on 11 Aug 2015 at 6:22
Original issue reported on code.google.com by
oshiro.h...@gmail.com
on 20 Jan 2015 at 3:18