Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,12 @@ Lib/test/test_unittest/testmock/ @cjw296
# Weakref
**/*weakref* @kumaraditya303

# Zlib
Doc/library/zlib.rst @StanFromIreland
Lib/compression/zlib.py @StanFromIreland
Lib/test/test_zlib.py @StanFromIreland
Modules/_zlibmodule.c @StanFromIreland

# Zipfile.Path
Lib/test/test_zipfile/_path/ @jaraco
Lib/zipfile/_path/ @jaraco
Expand Down
2 changes: 1 addition & 1 deletion Doc/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ Glossary
A piece of syntax which can be evaluated to some value. In other words,
an expression is an accumulation of expression elements like literals,
names, attribute access, operators or function calls which all return a
value. In contrast to many other languages, not all language constructs
value. Not all language constructs
are expressions. There are also :term:`statement`\s which cannot be used
as expressions, such as :keyword:`while`. Assignments are also statements,
not expressions.
Expand Down
3 changes: 3 additions & 0 deletions Lib/test/test_zlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ def test_combine_no_iv_invalid_length(self):
self.assertNotEqual(invalid_res, checksum)

self.assertRaises(TypeError, self.combine, 0, 0, "len")
self.assertRaises(ValueError, self.combine, 0, 0, -1)
self.assertRaises(OverflowError, self.combine, 0, 0, 2**1000)
self.assertRaises(OverflowError, self.combine, 0, 0, -2**1000)

def test_combine_with_iv(self):
for _ in range(self.N):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:func:`zlib.adler32_combine` and :func:`zlib.crc32_combine` now raise
:exc:`ValueError` if the *len2* argument is negative, instead of returning
rubbish or hanging indefinitely, respectively.
10 changes: 8 additions & 2 deletions Modules/zlibmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1948,7 +1948,10 @@ zlib_adler32_combine_impl(PyObject *module, unsigned int adler1,
#else
z_off_t len = convert_to_z_off_t(len2);
#endif
if (PyErr_Occurred()) {
if (len < 0) {
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_ValueError, "len2 must be non-negative");
}
return (unsigned int)-1;
}
return adler32_combine(adler1, adler2, len);
Expand Down Expand Up @@ -2033,7 +2036,10 @@ zlib_crc32_combine_impl(PyObject *module, unsigned int crc1,
#else
z_off_t len = convert_to_z_off_t(len2);
#endif
if (PyErr_Occurred()) {
if (len < 0) {
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_ValueError, "len2 must be non-negative");
}
return (unsigned int)-1;
}
return crc32_combine(crc1, crc2, len);
Expand Down
Loading