Commit 79b97ee2 authored by Christian Heimes's avatar Christian Heimes

Fix out of bounds read in long_new() for empty bytes with an explicit base....

Fix out of bounds read in long_new() for empty bytes with an explicit base. int(b'', somebase) calls PyLong_FromString() with char* of length 1 but the function accesses the first argument at offset 1. CID 715359
parent 4b2f9e91
......@@ -4149,8 +4149,8 @@ long_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
string = PyByteArray_AS_STRING(x);
else
string = PyBytes_AS_STRING(x);
if (strlen(string) != (size_t)size) {
/* We only see this if there's a null byte in x,
if (strlen(string) != (size_t)size || !size) {
/* We only see this if there's a null byte in x or x is empty,
x is a bytes or buffer, *and* a base is given. */
PyErr_Format(PyExc_ValueError,
"invalid literal for int() with base %d: %R",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment