This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace CHMLib\Header; |
||
4 | |||
5 | use Exception; |
||
6 | use CHMLib\Windows\Language; |
||
7 | use CHMLib\Reader\Reader; |
||
8 | use CHMLib\Exception\UnexpectedHeaderException; |
||
9 | |||
10 | /** |
||
11 | * The initial header of a CHM file. |
||
12 | */ |
||
13 | class ITSF extends VersionedHeader |
||
14 | { |
||
15 | /** |
||
16 | * The "timestamp" (lower 32 bits of a 64-bit value representing the number of centiseconds since 1601-01-01 00:00:00 UTC, plus 42). |
||
17 | * |
||
18 | * @var int |
||
19 | */ |
||
20 | protected $timestamp; |
||
21 | |||
22 | /** |
||
23 | * The language of the OS at the time of compilation. |
||
24 | * |
||
25 | * @var \CHMLib\Windows\Language |
||
26 | */ |
||
27 | protected $originalOSLanguage; |
||
28 | |||
29 | /** |
||
30 | * The directory GUID (it should be '{7C01FD10-7BAA-11D0-9E0C-00A0-C922-E6EC}'). |
||
31 | * |
||
32 | * @var string |
||
33 | */ |
||
34 | protected $directoryGUID; |
||
35 | |||
36 | /** |
||
37 | * The stream GUID (it should be '{7C01FD11-7BAA-11D0-9E0C-00A0-C922-E6EC}'). |
||
38 | * |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $streamGUID; |
||
42 | |||
43 | /** |
||
44 | * The offset of the section (from the beginning of the file). |
||
45 | * |
||
46 | * @var int |
||
47 | */ |
||
48 | protected $sectionOffset; |
||
49 | |||
50 | /** |
||
51 | * The length of the section. |
||
52 | * |
||
53 | * @var int |
||
54 | */ |
||
55 | protected $sectionLength; |
||
56 | |||
57 | /** |
||
58 | * The offset of the directory (from the beginning of the file). |
||
59 | * |
||
60 | * @var int |
||
61 | */ |
||
62 | protected $directoryOffset; |
||
63 | |||
64 | /** |
||
65 | * The length of the directory. |
||
66 | * |
||
67 | * @var int |
||
68 | */ |
||
69 | protected $directoryLength; |
||
70 | |||
71 | /** |
||
72 | * The offset of the content (from the beginning of the file). |
||
73 | * |
||
74 | * @var int |
||
75 | */ |
||
76 | protected $contentOffset; |
||
77 | |||
78 | /** |
||
79 | * Initialize the instance. |
||
80 | * |
||
81 | * @param Reader $reader The reader that provides the data. |
||
82 | * |
||
83 | * @throws \CHMLib\Exception\UnexpectedHeaderException Throws an UnexpectedHeaderException if the header signature is not valid. |
||
84 | * @throws \Exception Throws an Exception in case of errors. |
||
85 | */ |
||
86 | 4 | public function __construct(Reader $reader) |
|
87 | { |
||
88 | 4 | parent::__construct($reader); |
|
89 | 4 | if ($this->headerSignature !== 'ITSF') { |
|
90 | throw UnexpectedHeaderException::create('ITSF', $this->headerSignature); |
||
91 | } |
||
92 | 4 | if ($this->headerVersion < 2 || $this->headerVersion > 3) { |
|
93 | throw new Exception('Unsupported ITSF version number: '.$this->headerVersion); |
||
94 | } |
||
95 | 4 | /* Unknown (1) */ $reader->readUInt32(); |
|
96 | 4 | $this->timestamp = $reader->readUInt32(); |
|
97 | 4 | $this->originalOSLanguage = new Language($reader->readUInt32()); |
|
98 | 4 | $this->directoryGUID = $reader->readGUID(); |
|
99 | 4 | $this->streamGUID = $reader->readGUID(); |
|
100 | 4 | $this->sectionOffset = $reader->readUInt64(); |
|
0 ignored issues
–
show
|
|||
101 | 4 | $this->sectionLength = $reader->readUInt64(); |
|
0 ignored issues
–
show
It seems like
$reader->readUInt64() can also be of type double . However, the property $sectionLength is declared as type integer . Maybe add an additional type check?
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly. For example, imagine you have a variable Either this assignment is in error or a type check should be added for that assignment. class Id
{
public $id;
public function __construct($id)
{
$this->id = $id;
}
}
class Account
{
/** @var Id $id */
public $id;
}
$account_id = false;
if (starsAreRight()) {
$account_id = new Id(42);
}
$account = new Account();
if ($account instanceof Id)
{
$account->id = $account_id;
}
![]() |
|||
102 | 4 | $this->directoryOffset = $reader->readUInt64(); |
|
0 ignored issues
–
show
It seems like
$reader->readUInt64() can also be of type double . However, the property $directoryOffset is declared as type integer . Maybe add an additional type check?
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly. For example, imagine you have a variable Either this assignment is in error or a type check should be added for that assignment. class Id
{
public $id;
public function __construct($id)
{
$this->id = $id;
}
}
class Account
{
/** @var Id $id */
public $id;
}
$account_id = false;
if (starsAreRight()) {
$account_id = new Id(42);
}
$account = new Account();
if ($account instanceof Id)
{
$account->id = $account_id;
}
![]() |
|||
103 | 4 | $this->directoryLength = $reader->readUInt64(); |
|
0 ignored issues
–
show
It seems like
$reader->readUInt64() can also be of type double . However, the property $directoryLength is declared as type integer . Maybe add an additional type check?
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly. For example, imagine you have a variable Either this assignment is in error or a type check should be added for that assignment. class Id
{
public $id;
public function __construct($id)
{
$this->id = $id;
}
}
class Account
{
/** @var Id $id */
public $id;
}
$account_id = false;
if (starsAreRight()) {
$account_id = new Id(42);
}
$account = new Account();
if ($account instanceof Id)
{
$account->id = $account_id;
}
![]() |
|||
104 | 4 | if ($this->headerLength >= 96) { |
|
105 | 4 | $this->contentOffset = $reader->readUInt64(); |
|
0 ignored issues
–
show
It seems like
$reader->readUInt64() can also be of type double . However, the property $contentOffset is declared as type integer . Maybe add an additional type check?
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly. For example, imagine you have a variable Either this assignment is in error or a type check should be added for that assignment. class Id
{
public $id;
public function __construct($id)
{
$this->id = $id;
}
}
class Account
{
/** @var Id $id */
public $id;
}
$account_id = false;
if (starsAreRight()) {
$account_id = new Id(42);
}
$account = new Account();
if ($account instanceof Id)
{
$account->id = $account_id;
}
![]() |
|||
106 | } else { |
||
107 | $this->contentOffset = $this->directoryOffset + $this->directoryLength; |
||
0 ignored issues
–
show
The property
$contentOffset was declared of type integer , but $this->directoryOffset + $this->directoryLength is of type double . Maybe add a type cast?
This check looks for assignments to scalar types that may be of the wrong type. To ensure the code behaves as expected, it may be a good idea to add an explicit type cast. $answer = 42;
$correct = false;
$correct = (bool) $answer;
![]() |
|||
108 | } |
||
109 | 4 | } |
|
110 | |||
111 | /** |
||
112 | * Get the "timestamp" (lower 32 bits of a 64-bit value representing the number of centiseconds since 1601-01-01 00:00:00 UTC, plus 42). |
||
113 | * |
||
114 | * @return int |
||
115 | */ |
||
116 | public function getTimestamp() |
||
117 | { |
||
118 | return $this->timestamp; |
||
119 | } |
||
120 | |||
121 | /** |
||
122 | * Get the language of the OS at the time of compilation. |
||
123 | * |
||
124 | * @return \CHMLib\Windows\Language |
||
125 | */ |
||
126 | public function getOriginalOSLanguage() |
||
127 | { |
||
128 | return $this->originalOSLanguage; |
||
129 | } |
||
130 | |||
131 | /** |
||
132 | * Get the directory GUID (it should be '{7C01FD10-7BAA-11D0-9E0C-00A0-C922-E6EC}'). |
||
133 | * |
||
134 | * @return string |
||
135 | */ |
||
136 | public function getDirectoryGUID() |
||
137 | { |
||
138 | return $this->directoryGUID; |
||
139 | } |
||
140 | |||
141 | /** |
||
142 | * Get the stream GUID (it should be '{7C01FD11-7BAA-11D0-9E0C-00A0-C922-E6EC}'). |
||
143 | * |
||
144 | * @return string |
||
145 | */ |
||
146 | public function getStreamGUID() |
||
147 | { |
||
148 | return $this->streamGUID; |
||
149 | } |
||
150 | |||
151 | /** |
||
152 | * Get the offset of the section (from the beginning of the file). |
||
153 | * |
||
154 | * @return int |
||
155 | */ |
||
156 | 4 | public function getSectionOffset() |
|
157 | { |
||
158 | 4 | return $this->sectionOffset; |
|
159 | } |
||
160 | |||
161 | /** |
||
162 | * Get the length of section. |
||
163 | * |
||
164 | * @return int |
||
165 | */ |
||
166 | 4 | public function getSectionLength() |
|
167 | { |
||
168 | 4 | return $this->sectionLength; |
|
169 | } |
||
170 | |||
171 | /** |
||
172 | * Get the offset of the directory (from the beginning of the file). |
||
173 | * |
||
174 | * @return int |
||
175 | */ |
||
176 | 4 | public function getDirectoryOffset() |
|
177 | { |
||
178 | 4 | return $this->directoryOffset; |
|
179 | } |
||
180 | |||
181 | /** |
||
182 | * Get the length of the directory. |
||
183 | * |
||
184 | * @return int |
||
185 | */ |
||
186 | 4 | public function getDirectoryLength() |
|
187 | { |
||
188 | 4 | return $this->directoryLength; |
|
189 | } |
||
190 | |||
191 | /** |
||
192 | * Get the offset of the content (from the beginning of the file). |
||
193 | * |
||
194 | * @return int |
||
195 | */ |
||
196 | 4 | public function getContentOffset() |
|
197 | { |
||
198 | 4 | return $this->contentOffset; |
|
199 | } |
||
200 | } |
||
201 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.