Skip to content
Open
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
4 changes: 2 additions & 2 deletions magic/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def getparam(self, param):
Returns the param value if successful and -1 if the parameter
was unknown.
"""
v = c_int()
v = c_size_t()
i = _getparam(self._magic_t, param, byref(v))
if i == -1:
return -1
Expand All @@ -254,7 +254,7 @@ def setparam(self, param, value):
"""
Returns 0 if successful and -1 if the parameter was unknown.
"""
v = c_int(value)
v = c_size_t(value)
return _setparam(self._magic_t, param, byref(v))


Expand Down
8 changes: 8 additions & 0 deletions test/python_magic_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,14 @@ def test_version(self):
except NotImplementedError:
pass


def test_compat_params_use_size_t(self):
# libmagic reads and writes setparam/getparam values as a size_t,
# so the compat module must not truncate them to 32 bits.
m = magic.compat.open(magic.compat.MAGIC_NONE)
self.assertEqual(0, m.setparam(magic.compat.PARAM_BYTES_MAX, 2**33))
self.assertEqual(2**33, m.getparam(magic.compat.PARAM_BYTES_MAX))

def test_fs_encoding(self):
self.assertEqual("utf-8", sys.getfilesystemencoding().lower())

Expand Down