MCPcopy Create free account
hub / github.com/R-Fuzz/symsan / ResetParser

Function ResetParser

python/symsan-py.cpp:311–351  ·  view source on GitHub ↗

Reset parser with new input data

Source from the content-addressed store, hash-verified

309
310// Reset parser with new input data
311static PyObject* ResetParser(PyObject *self, PyObject *args) {
312 if (__z3_parser == nullptr) {
313 PyErr_SetString(PyExc_RuntimeError, "parser not initialized");
314 return NULL;
315 }
316
317 std::vector<symsan::input_t> inputs;
318 PyObject *iargs = NULL;
319
320 if (!PyArg_ParseTuple(args, "O!", &PyList_Type, &iargs)) {
321 return NULL;
322 }
323
324 Py_ssize_t argc = PyList_Size(iargs);
325 for (Py_ssize_t i = 0; i < argc; i++) {
326 PyObject *item = PyList_GetItem(iargs, i);
327 if (item == NULL) {
328 PyErr_SetString(PyExc_RuntimeError, "failed to retrieve args list");
329 return NULL;
330 }
331 if (!PyBytes_Check(item)) {
332 PyErr_SetString(PyExc_TypeError, "args must be a list of bytes");
333 return NULL;
334 }
335 Py_ssize_t size;
336 char *data;
337 if (PyBytes_AsStringAndSize(item, &data, &size) != 0) {
338 // exception should have been set?
339 return NULL;
340 }
341 inputs.push_back({(uint8_t*)data, size});
342 }
343
344 // Always copy input data in Python to avoid dangling pointers
345 if (__z3_parser->restart(inputs, true) != 0) {
346 PyErr_SetString(PyExc_RuntimeError, "failed to restart parser");
347 return NULL;
348 }
349
350 Py_RETURN_NONE;
351}
352
353// Update input cache without clearing deps (for late-arriving GV data)
354static PyObject* UpdateInput(PyObject *self, PyObject *args) {

Callers

nothing calls this directly

Calls 2

push_backMethod · 0.45
restartMethod · 0.45

Tested by

no test coverage detected