mirror of
https://github.com/cemu-project/idapython.git
synced 2025-01-14 02:49:12 +01:00
vuln bugfix: check for swig_runtime_dataN.py was not done properly (MSVR-11-0084)
The bug is due to the following faulty line: http://code.google.com/p/idapython/source/browse/tags/build-1.5.1/swig/idaapi.i#611
This commit is contained in:
parent
8413f9f791
commit
7bd77d534c
28
python.cpp
28
python.cpp
@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
// Python-style version tuple comes from the makefile
|
// Python-style version tuple comes from the makefile
|
||||||
// Only the serial and status is set here
|
// Only the serial and status is set here
|
||||||
#define VER_SERIAL 0
|
#define VER_SERIAL 3
|
||||||
#define VER_STATUS "final"
|
#define VER_STATUS "final"
|
||||||
#define IDAPYTHON_RUNSTATEMENT 0
|
#define IDAPYTHON_RUNSTATEMENT 0
|
||||||
#define IDAPYTHON_ENABLE_EXTLANG 3
|
#define IDAPYTHON_ENABLE_EXTLANG 3
|
||||||
@ -205,7 +205,7 @@ void disable_script_timeout()
|
|||||||
{
|
{
|
||||||
// Clear timeout
|
// Clear timeout
|
||||||
script_timeout = 0;
|
script_timeout = 0;
|
||||||
|
|
||||||
// Uninstall the trace function and hide the waitbox (if it was shown)
|
// Uninstall the trace function and hide the waitbox (if it was shown)
|
||||||
end_execution();
|
end_execution();
|
||||||
}
|
}
|
||||||
@ -215,7 +215,7 @@ int set_script_timeout(int timeout)
|
|||||||
{
|
{
|
||||||
// Update the timeout
|
// Update the timeout
|
||||||
qswap(timeout, script_timeout);
|
qswap(timeout, script_timeout);
|
||||||
|
|
||||||
// Reset the execution time and hide the waitbox (so it is shown again after timeout elapses)
|
// Reset the execution time and hide the waitbox (so it is shown again after timeout elapses)
|
||||||
reset_execution_time();
|
reset_execution_time();
|
||||||
hide_script_waitbox();
|
hide_script_waitbox();
|
||||||
@ -353,7 +353,7 @@ static PyObject *GetMainGlobals()
|
|||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
static void PythonEvalOrExec(
|
static void PythonEvalOrExec(
|
||||||
const char *str,
|
const char *str,
|
||||||
const char *filename = "<string>")
|
const char *filename = "<string>")
|
||||||
{
|
{
|
||||||
// Compile as an expression
|
// Compile as an expression
|
||||||
@ -411,7 +411,7 @@ static error_t idaapi idc_runpythonstatement(idc_value_t *argv, idc_value_t *res
|
|||||||
Py_file_input,
|
Py_file_input,
|
||||||
globals,
|
globals,
|
||||||
globals);
|
globals);
|
||||||
PYW_GIL_RELEASE;
|
PYW_GIL_RELEASE;
|
||||||
Py_XDECREF(result);
|
Py_XDECREF(result);
|
||||||
end_execution();
|
end_execution();
|
||||||
|
|
||||||
@ -513,13 +513,13 @@ static int PyRunFile(const char *FileName)
|
|||||||
|
|
||||||
PYW_GIL_ENSURE;
|
PYW_GIL_ENSURE;
|
||||||
PyObject *result = PyRun_File(
|
PyObject *result = PyRun_File(
|
||||||
PyFile_AsFile(PyFileObject),
|
PyFile_AsFile(PyFileObject),
|
||||||
FileName,
|
FileName,
|
||||||
Py_file_input,
|
Py_file_input,
|
||||||
globals,
|
globals,
|
||||||
globals);
|
globals);
|
||||||
PYW_GIL_RELEASE;
|
PYW_GIL_RELEASE;
|
||||||
|
|
||||||
Py_XDECREF(PyFileObject);
|
Py_XDECREF(PyFileObject);
|
||||||
Py_XDECREF(result);
|
Py_XDECREF(result);
|
||||||
|
|
||||||
@ -760,7 +760,7 @@ bool idaapi IDAPython_extlang_run(
|
|||||||
|
|
||||||
if ( imported_module )
|
if ( imported_module )
|
||||||
{
|
{
|
||||||
PYW_GIL_ENSURE;
|
PYW_GIL_ENSURE;
|
||||||
module = PyImport_ImportModule(modname);
|
module = PyImport_ImportModule(modname);
|
||||||
PYW_GIL_RELEASE;
|
PYW_GIL_RELEASE;
|
||||||
}
|
}
|
||||||
@ -1163,7 +1163,7 @@ bool idaapi IDAPython_cli_execute_line(const char *line)
|
|||||||
// Pseudo commands
|
// Pseudo commands
|
||||||
//
|
//
|
||||||
qstring s;
|
qstring s;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
// Help command?
|
// Help command?
|
||||||
if ( line[0] == '?' )
|
if ( line[0] == '?' )
|
||||||
@ -1402,10 +1402,10 @@ bool IDAPython_Init(void)
|
|||||||
|
|
||||||
// Read configuration value
|
// Read configuration value
|
||||||
read_user_config_file("python.cfg", set_python_options, NULL);
|
read_user_config_file("python.cfg", set_python_options, NULL);
|
||||||
if ( g_alert_auto_scripts )
|
if ( g_alert_auto_scripts )
|
||||||
{
|
{
|
||||||
const char *autofn = pywraps_check_autoscripts();
|
const char *autofn = pywraps_check_autoscripts();
|
||||||
if ( autofn != NULL
|
if ( autofn != NULL
|
||||||
&& askyn_c(0, "HIDECANCEL\nTITLE IDAPython\nThe script '%s' was found in the current directory and will be automatically executed by Python.\n\n"
|
&& askyn_c(0, "HIDECANCEL\nTITLE IDAPython\nThe script '%s' was found in the current directory and will be automatically executed by Python.\n\n"
|
||||||
"Do you want to continue loading IDAPython?", autofn) == 0 )
|
"Do you want to continue loading IDAPython?", autofn) == 0 )
|
||||||
{
|
{
|
||||||
|
@ -151,9 +151,9 @@ class pycvt_t
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
static int get_attr(
|
static int get_attr(
|
||||||
PyObject *py_obj,
|
PyObject *py_obj,
|
||||||
const char *attrname,
|
const char *attrname,
|
||||||
int ft,
|
int ft,
|
||||||
attr_t &val)
|
attr_t &val)
|
||||||
{
|
{
|
||||||
PyObject *py_attr;
|
PyObject *py_attr;
|
||||||
@ -166,7 +166,7 @@ class pycvt_t
|
|||||||
else if ( (ft > FT_FIRST_NUM && ft < FT_LAST_NUM) && PyW_GetNumber(py_attr, &val.u64) )
|
else if ( (ft > FT_FIRST_NUM && ft < FT_LAST_NUM) && PyW_GetNumber(py_attr, &val.u64) )
|
||||||
; // nothing to be done
|
; // nothing to be done
|
||||||
// A string array?
|
// A string array?
|
||||||
else if ( (ft == FT_STRARR || ft == FT_NUM16ARR || ft == FT_CHRARR_STATIC )
|
else if ( (ft == FT_STRARR || ft == FT_NUM16ARR || ft == FT_CHRARR_STATIC )
|
||||||
&& (PyList_CheckExact(py_attr) || PyW_IsSequenceType(py_attr)) )
|
&& (PyList_CheckExact(py_attr) || PyW_IsSequenceType(py_attr)) )
|
||||||
{
|
{
|
||||||
// Return a reference to the attribute
|
// Return a reference to the attribute
|
||||||
@ -182,8 +182,8 @@ class pycvt_t
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
static int idaapi make_str_list_cb(
|
static int idaapi make_str_list_cb(
|
||||||
PyObject *py_item,
|
PyObject *py_item,
|
||||||
Py_ssize_t index,
|
Py_ssize_t index,
|
||||||
void *ud)
|
void *ud)
|
||||||
{
|
{
|
||||||
if ( !PyString_Check(py_item) )
|
if ( !PyString_Check(py_item) )
|
||||||
@ -201,19 +201,19 @@ class pycvt_t
|
|||||||
{
|
{
|
||||||
// Take the size
|
// Take the size
|
||||||
Py_ssize_t size = pyvar_walk_list(py_list);
|
Py_ssize_t size = pyvar_walk_list(py_list);
|
||||||
|
|
||||||
// Allocate a buffer
|
// Allocate a buffer
|
||||||
char **a = (char **)qalloc((size + 1) * sizeof(char *));
|
char **a = (char **)qalloc((size + 1) * sizeof(char *));
|
||||||
|
|
||||||
// Walk and populate
|
// Walk and populate
|
||||||
size = pyvar_walk_list(py_list, make_str_list_cb, a);
|
size = pyvar_walk_list(py_list, make_str_list_cb, a);
|
||||||
|
|
||||||
// Make the list NULL terminated
|
// Make the list NULL terminated
|
||||||
a[size] = NULL;
|
a[size] = NULL;
|
||||||
|
|
||||||
// Return the list to the user
|
// Return the list to the user
|
||||||
*arr = a;
|
*arr = a;
|
||||||
|
|
||||||
// Return the size of items processed
|
// Return the size of items processed
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
@ -221,8 +221,8 @@ class pycvt_t
|
|||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
typedef qvector<uint64> uint64vec_t;
|
typedef qvector<uint64> uint64vec_t;
|
||||||
static int idaapi make_int_list(
|
static int idaapi make_int_list(
|
||||||
PyObject *py_item,
|
PyObject *py_item,
|
||||||
Py_ssize_t /*index*/,
|
Py_ssize_t /*index*/,
|
||||||
void *ud)
|
void *ud)
|
||||||
{
|
{
|
||||||
uint64 val;
|
uint64 val;
|
||||||
@ -344,7 +344,7 @@ public:
|
|||||||
}
|
}
|
||||||
return ok ? -1 : i;
|
return ok ? -1 : i;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
// Converts fields from IDC and field description into a C structure
|
// Converts fields from IDC and field description into a C structure
|
||||||
// If 'use_extlang' is specified, then the passed idc_obj is considered
|
// If 'use_extlang' is specified, then the passed idc_obj is considered
|
||||||
@ -369,13 +369,13 @@ public:
|
|||||||
|
|
||||||
// Get field type
|
// Get field type
|
||||||
int ft = fd.field_type & ~FT_VALUE_MASK;
|
int ft = fd.field_type & ~FT_VALUE_MASK;
|
||||||
|
|
||||||
// Point to structure member
|
// Point to structure member
|
||||||
void *store = (void *)((char *)store_area + fd.field_offs);
|
void *store = (void *)((char *)store_area + fd.field_offs);
|
||||||
|
|
||||||
// Retrieve attribute and type
|
// Retrieve attribute and type
|
||||||
int cvt = get_attr(py_obj, fd.field_name, ft, attr);
|
int cvt = get_attr(py_obj, fd.field_name, ft, attr);
|
||||||
|
|
||||||
// Attribute not found?
|
// Attribute not found?
|
||||||
if ( cvt == FT_NOT_FOUND )
|
if ( cvt == FT_NOT_FOUND )
|
||||||
{
|
{
|
||||||
@ -458,7 +458,7 @@ public:
|
|||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
Py_ssize_t pyvar_walk_list(
|
Py_ssize_t pyvar_walk_list(
|
||||||
PyObject *py_list,
|
PyObject *py_list,
|
||||||
int (idaapi *cb)(PyObject *py_item, Py_ssize_t index, void *ud),
|
int (idaapi *cb)(PyObject *py_item, Py_ssize_t index, void *ud),
|
||||||
void *ud)
|
void *ud)
|
||||||
{
|
{
|
||||||
@ -480,7 +480,7 @@ Py_ssize_t pyvar_walk_list(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
int r = cb(py_item, i, ud);
|
int r = cb(py_item, i, ud);
|
||||||
|
|
||||||
// Decrement reference (if needed)
|
// Decrement reference (if needed)
|
||||||
if ( r != CIP_OK_NODECREF && is_seq )
|
if ( r != CIP_OK_NODECREF && is_seq )
|
||||||
Py_DECREF(py_item); // Only sequences require us to decrement the reference
|
Py_DECREF(py_item); // Only sequences require us to decrement the reference
|
||||||
@ -504,8 +504,8 @@ PyObject *PyW_IntVecToPyList(const intvec_t &intvec)
|
|||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
static int idaapi pylist_to_intvec_cb(
|
static int idaapi pylist_to_intvec_cb(
|
||||||
PyObject *py_item,
|
PyObject *py_item,
|
||||||
Py_ssize_t /*index*/,
|
Py_ssize_t /*index*/,
|
||||||
void *ud)
|
void *ud)
|
||||||
{
|
{
|
||||||
intvec_t &intvec = *(intvec_t *)ud;
|
intvec_t &intvec = *(intvec_t *)ud;
|
||||||
@ -1124,13 +1124,11 @@ struct py_add_del_menu_item_ctx
|
|||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
const char *pywraps_check_autoscripts()
|
const char *pywraps_check_autoscripts()
|
||||||
{
|
{
|
||||||
#define STRING1(x) #x
|
|
||||||
#define STRING2(x) STRING1(x)
|
|
||||||
static const char *exts[] = {"py", "pyw", "pyc", "pyo"};
|
static const char *exts[] = {"py", "pyw", "pyc", "pyo"};
|
||||||
|
|
||||||
static const char *fns[] =
|
static const char *fns[] =
|
||||||
{
|
{
|
||||||
"swig_runtime_data" STRING2(SWIG_RUNTIME_VERSION),
|
"swig_runtime_data" SWIG_RUNTIME_VERSION,
|
||||||
"sitecustomize",
|
"sitecustomize",
|
||||||
"usercustomize"
|
"usercustomize"
|
||||||
};
|
};
|
||||||
@ -1146,8 +1144,6 @@ const char *pywraps_check_autoscripts()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
#undef STRING1
|
|
||||||
#undef STRING2
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
@ -1178,7 +1174,7 @@ bool init_pywraps()
|
|||||||
char dtor_name[MAXSTR];
|
char dtor_name[MAXSTR];
|
||||||
qsnprintf(dtor_name, sizeof(dtor_name), "%s.dtor", S_PY_IDC_OPAQUE_T);
|
qsnprintf(dtor_name, sizeof(dtor_name), "%s.dtor", S_PY_IDC_OPAQUE_T);
|
||||||
|
|
||||||
// register the dtor function
|
// Register the dtor function
|
||||||
if ( !set_idc_func_ex(dtor_name, py_idc_opaque_dtor, py_idc_cvt_helper_dtor_args, 0) )
|
if ( !set_idc_func_ex(dtor_name, py_idc_opaque_dtor, py_idc_cvt_helper_dtor_args, 0) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user