mirror of
https://github.com/python/cpython.git
synced 2026-02-22 07:00:51 +00:00
gh-145058: Add input validation to _PyImport_LazyImportModuleLevelObject (#145068)
This commit is contained in:
parent
0499a0c17f
commit
e1bd0cd37b
3 changed files with 22 additions and 0 deletions
|
|
@ -4468,6 +4468,17 @@ _PyImport_LazyImportModuleLevelObject(PyThreadState *tstate,
|
|||
PyObject *globals, PyObject *locals,
|
||||
PyObject *fromlist, int level)
|
||||
{
|
||||
assert(name != NULL);
|
||||
if (!PyUnicode_Check(name)) {
|
||||
_PyErr_Format(tstate, PyExc_TypeError,
|
||||
"module name must be a string, got %T", name);
|
||||
return NULL;
|
||||
}
|
||||
if (level < 0) {
|
||||
_PyErr_SetString(tstate, PyExc_ValueError, "level must be >= 0");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PyObject *abs_name = get_abs_name(tstate, name, globals, level);
|
||||
if (abs_name == NULL) {
|
||||
return NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue