PyDrivers: update bytecode check for Python3.6
This commit is contained in:
@@ -253,7 +253,6 @@ static void pydriver_error(ChannelDriver *driver)
|
|||||||
#define OK_OP(op) [op] = 1
|
#define OK_OP(op) [op] = 1
|
||||||
|
|
||||||
const char secure_opcodes[255] = {
|
const char secure_opcodes[255] = {
|
||||||
OK_OP(0),
|
|
||||||
OK_OP(POP_TOP),
|
OK_OP(POP_TOP),
|
||||||
OK_OP(ROT_TWO),
|
OK_OP(ROT_TWO),
|
||||||
OK_OP(ROT_THREE),
|
OK_OP(ROT_THREE),
|
||||||
@@ -347,15 +346,14 @@ static bool bpy_driver_secure_bytecode_validate(PyObject *expr_code, PyObject *d
|
|||||||
|
|
||||||
/* Check opcodes. */
|
/* Check opcodes. */
|
||||||
{
|
{
|
||||||
const char *codestr;
|
const _Py_CODEUNIT *codestr;
|
||||||
Py_ssize_t code_len;
|
Py_ssize_t code_len;
|
||||||
|
|
||||||
PyBytes_AsStringAndSize(py_code->co_code, (char **)&codestr, &code_len);
|
PyBytes_AsStringAndSize(py_code->co_code, (char **)&codestr, &code_len);
|
||||||
|
code_len /= sizeof(*codestr);
|
||||||
|
|
||||||
#define CODESIZE(op) (HAS_ARG(op) ? 3 : 1)
|
for (Py_ssize_t i = 0; i < code_len; i++) {
|
||||||
|
const int opcode = _Py_OPCODE(codestr[i]);
|
||||||
for (Py_ssize_t i = 0; i < code_len; i += CODESIZE(codestr[i])) {
|
|
||||||
const int opcode = codestr[i];
|
|
||||||
if (secure_opcodes[opcode] == 0) {
|
if (secure_opcodes[opcode] == 0) {
|
||||||
fprintf(stderr, "\tBPY_driver_eval() - restructed access disallows opcode '%d', "
|
fprintf(stderr, "\tBPY_driver_eval() - restructed access disallows opcode '%d', "
|
||||||
"enable auto-execution to support\n", opcode);
|
"enable auto-execution to support\n", opcode);
|
||||||
|
Reference in New Issue
Block a user