MCPcopy Index your code
hub / github.com/python/cpython / OffsetValidationTests

Class OffsetValidationTests

Lib/test/test_tarfile.py:4703–4855  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4701
4702
4703class OffsetValidationTests(unittest.TestCase):
4704 tarname = tmpname
4705 invalid_posix_header = (
4706 # name: 100 bytes
4707 tarfile.NUL * tarfile.LENGTH_NAME
4708 # mode, space, null terminator: 8 bytes
4709 + b"000755" + SPACE + tarfile.NUL
4710 # uid, space, null terminator: 8 bytes
4711 + b"000001" + SPACE + tarfile.NUL
4712 # gid, space, null terminator: 8 bytes
4713 + b"000001" + SPACE + tarfile.NUL
4714 # size, space: 12 bytes
4715 + b"\xff" * 11 + SPACE
4716 # mtime, space: 12 bytes
4717 + tarfile.NUL * 11 + SPACE
4718 # chksum: 8 bytes
4719 + b"0011407" + tarfile.NUL
4720 # type: 1 byte
4721 + tarfile.REGTYPE
4722 # linkname: 100 bytes
4723 + tarfile.NUL * tarfile.LENGTH_LINK
4724 # magic: 6 bytes, version: 2 bytes
4725 + tarfile.POSIX_MAGIC
4726 # uname: 32 bytes
4727 + tarfile.NUL * 32
4728 # gname: 32 bytes
4729 + tarfile.NUL * 32
4730 # devmajor, space, null terminator: 8 bytes
4731 + tarfile.NUL * 6 + SPACE + tarfile.NUL
4732 # devminor, space, null terminator: 8 bytes
4733 + tarfile.NUL * 6 + SPACE + tarfile.NUL
4734 # prefix: 155 bytes
4735 + tarfile.NUL * tarfile.LENGTH_PREFIX
4736 # padding: 12 bytes
4737 + tarfile.NUL * 12
4738 )
4739 invalid_gnu_header = (
4740 # name: 100 bytes
4741 tarfile.NUL * tarfile.LENGTH_NAME
4742 # mode, null terminator: 8 bytes
4743 + b"0000755" + tarfile.NUL
4744 # uid, null terminator: 8 bytes
4745 + b"0000001" + tarfile.NUL
4746 # gid, space, null terminator: 8 bytes
4747 + b"0000001" + tarfile.NUL
4748 # size, space: 12 bytes
4749 + b"\xff" * 11 + SPACE
4750 # mtime, space: 12 bytes
4751 + tarfile.NUL * 11 + SPACE
4752 # chksum: 8 bytes
4753 + b"0011327" + tarfile.NUL
4754 # type: 1 byte
4755 + tarfile.REGTYPE
4756 # linkname: 100 bytes
4757 + tarfile.NUL * tarfile.LENGTH_LINK
4758 # magic: 8 bytes
4759 + tarfile.GNU_MAGIC
4760 # uname: 32 bytes

Callers

nothing calls this directly

Calls 1

tobufMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…