diff options
| author | Julian Andres Klode <jak@debian.org> | 2015-06-11 16:15:34 +0200 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2015-06-11 16:15:34 +0200 |
| commit | 3ae6e69473c785b6c56cfb27c31a7c9375416f06 (patch) | |
| tree | ca40a4883e0a6ee3add162078781c4b714d6208f /tests | |
| parent | a6e3d4d872b852de308f19a15215180cb4116765 (diff) | |
| download | python-apt-3ae6e69473c785b6c56cfb27c31a7c9375416f06.tar.gz | |
python/tarfile.cc: LFS: Handle too large file
Handle both file sizes larger than SIZE_MAX and allocation
failures when reading the data of a tarmember.
If using the go() function with a callback, pass None as the data
parameter for files that are too large. For extractdata, raise
a MemoryError if the file too extract is too large.
Also check for an existing error first in extractdata, before
raising a new one.
Test the whole thing on 32-bit platforms with a sample deb that
contains a zeroed file that is 5GB large (compressed using xz
at level 1 to a few kb).
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/data/test_debs/large-package-content_1.0_all.deb | bin | 0 -> 781546 bytes | |||
| -rw-r--r-- | tests/test_large_file.py | 22 |
2 files changed, 22 insertions, 0 deletions
diff --git a/tests/data/test_debs/large-package-content_1.0_all.deb b/tests/data/test_debs/large-package-content_1.0_all.deb Binary files differnew file mode 100644 index 00000000..56bdce3d --- /dev/null +++ b/tests/data/test_debs/large-package-content_1.0_all.deb diff --git a/tests/test_large_file.py b/tests/test_large_file.py new file mode 100644 index 00000000..2e873131 --- /dev/null +++ b/tests/test_large_file.py @@ -0,0 +1,22 @@ +#!/usr/bin/python + +import sys +import unittest + +import apt_inst + +IS_NOT_32BIT = sys.maxsize > 2**32 + +@unittest.skipIf(IS_NOT_32BIT, "Large File support is for 32 bit systems") +class testHashes(unittest.TestCase): + " test the hashsum functions against strings and files " + + LARGE_PACKAGE_CONTENT = "data/test_debs/large-package-content_1.0_all.deb" + + def testExtractData(self): + deb = apt_inst.DebFile(self.LARGE_PACKAGE_CONTENT) + + self.assertRaises(MemoryError, deb.data.extractdata, "large-file") + +if __name__ == "__main__": + unittest.main() |
