File: test_fuzz_results.py

package info (click to toggle)
python-biplist 1.0.3-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 380 kB
  • sloc: python: 1,419; makefile: 3
file content (121 lines) | stat: -rw-r--r-- 4,046 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# -*- coding: utf-8 -*-

from biplist import *
import os
from test_utils import *
import unittest

class TestFuzzResults(unittest.TestCase):
    def setUp(self):
        pass
    
    def testCurrentOffsetOutOfRange(self):
        try:
            readPlist(fuzz_data_path('list_index_out_of_range.plist'))
            self.fail("list index out of range, should fail")
        except NotBinaryPlistException as e:
            pass
        except InvalidPlistException as e:
            pass
    
    def testInvalidMarkerByteUnpack(self):
        try:
            readPlist(fuzz_data_path('no_marker_byte.plist'))
            self.fail("No marker byte at object offset")
        except NotBinaryPlistException as e:
            pass
        except InvalidPlistException as e:
            pass
    
    def testInvalidObjectOffset(self):
        try:
            readPlist(fuzz_data_path('invalid_object_offset.plist'))
            self.fail("Invalid object offset in offsets table")
        except NotBinaryPlistException as e:
            pass
        except InvalidPlistException as e:
            pass
    
    def testRecursiveObjectOffset(self):
        try:
            readPlist(fuzz_data_path('recursive_object_offset.plist'))
            self.fail("Recursive object found")
        except NotBinaryPlistException as e:
            pass
        except InvalidPlistException as e:
            pass
    
    def testExcessivelyLongAsciiString(self):
        try:
            readPlist(fuzz_data_path('ascii_string_too_long.plist'))
            self.fail("ASCII string extends into trailer")
        except NotBinaryPlistException as e:
            pass
        except InvalidPlistException as e:
            pass
    
    def testNegativelyLongAsciiString(self):
        try:
            readPlist(fuzz_data_path('ascii_string_negative_length.plist'))
            self.fail("ASCII string length less than zero")
        except NotBinaryPlistException as e:
            pass
        except InvalidPlistException as e:
            pass
    
    def testInvalidOffsetEnding(self):
        # The end of the offset is past the end of the offset table.
        try:
            readPlist(fuzz_data_path('invalid_offset_ending.plist'))
            self.fail("End of offset after end of offset table")
        except NotBinaryPlistException as e:
            pass
        except InvalidPlistException as e:
            pass
    
    def testInvalidDictionaryObjectCount(self):
        try:
            readPlist(fuzz_data_path('dictionary_invalid_count.plist'))
            self.fail("Dictionary object count is not of integer type")
        except NotBinaryPlistException as e:
            pass
        except InvalidPlistException as e:
            pass
    
    def testInvalidArrayObjectCount(self):
        try:
            readPlist(fuzz_data_path('array_invalid_count.plist'))
            self.fail("Array object count is not of integer type")
        except NotBinaryPlistException as e:
            pass
        except InvalidPlistException as e:
            pass
    
    def testInvalidRealLength(self):
        # We shouldn't have been checking for extra length reals, anyway.
        try:
            readPlist(fuzz_data_path('real_invalid_length.plist'))
            self.fail("Real length is not of integer type")
        except NotBinaryPlistException as e:
            pass
        except InvalidPlistException as e:
            pass
    
    def testNaNDateSeconds(self):
        try:
            readPlist(fuzz_data_path('date_seconds_is_nan.plist'))
            self.fail("Date seconds is NaN")
        except NotBinaryPlistException as e:
            pass
        except InvalidPlistException as e:
            pass
    
    def testIntegerWithZeroByteLength(self):
        try:
            readPlist(fuzz_data_path('integer_zero_byte_length.plist'))
            self.fail("Integer has byte size of 0.")
        except NotBinaryPlistException as e:
            pass
        except InvalidPlistException as e:
            pass