Skip to content
Snippets Groups Projects
Commit 19a915d43a68 authored by Adrian Buehlmann's avatar Adrian Buehlmann
Browse files

base85: cast Py_ssize_t values to int (issue3481)

If it outputs a nonsense value, no harm done, it was nonsense to start with.
parent cda5402b1739
No related branches found
No related tags found
No related merge requests found
......@@ -111,7 +111,8 @@
if (c < 0)
return PyErr_Format(
PyExc_ValueError,
"bad base85 character at position %d", i);
"bad base85 character at position %d",
(int)i);
acc = acc * 85 + c;
}
if (i++ < len)
......@@ -120,9 +121,10 @@
if (c < 0)
return PyErr_Format(
PyExc_ValueError,
"bad base85 character at position %d", i);
"bad base85 character at position %d",
(int)i);
/* overflow detection: 0xffffffff == "|NsC0",
* "|NsC" == 0x03030303 */
if (acc > 0x03030303 || (acc *= 85) > 0xffffffff - c)
return PyErr_Format(
PyExc_ValueError,
......@@ -124,9 +126,10 @@
/* overflow detection: 0xffffffff == "|NsC0",
* "|NsC" == 0x03030303 */
if (acc > 0x03030303 || (acc *= 85) > 0xffffffff - c)
return PyErr_Format(
PyExc_ValueError,
"bad base85 sequence at position %d", i);
"bad base85 sequence at position %d",
(int)i);
acc += c;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment