Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
osticket
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
docker
osticket
Commits
ba637776
Commit
ba637776
authored
11 years ago
by
Jared Hancock
Browse files
Options
Downloads
Patches
Plain Diff
tnef: Detect corrupted TNEF streams
parent
ac42e624
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/class.mailparse.php
+13
-4
13 additions, 4 deletions
include/class.mailparse.php
include/tnef_decoder.php
+21
-10
21 additions, 10 deletions
include/tnef_decoder.php
with
34 additions
and
14 deletions
include/class.mailparse.php
+
13
−
4
View file @
ba637776
...
@@ -46,6 +46,8 @@ class Mail_Parse {
...
@@ -46,6 +46,8 @@ class Mail_Parse {
//Desired charset
//Desired charset
if
(
$charset
)
if
(
$charset
)
$this
->
charset
=
$charset
;
$this
->
charset
=
$charset
;
$this
->
notes
=
array
();
}
}
function
decode
()
{
function
decode
()
{
...
@@ -95,10 +97,17 @@ class Mail_Parse {
...
@@ -95,10 +97,17 @@ class Mail_Parse {
foreach
(
$this
->
struct
->
parts
as
$i
=>
$part
)
{
foreach
(
$this
->
struct
->
parts
as
$i
=>
$part
)
{
if
(
!
$part
->
parts
&&
$part
->
ctype_primary
==
'application'
if
(
!
$part
->
parts
&&
$part
->
ctype_primary
==
'application'
&&
$part
->
ctype_secondary
==
'ms-tnef'
)
{
&&
$part
->
ctype_secondary
==
'ms-tnef'
)
{
$tnef
=
new
TnefStreamParser
(
$part
->
body
);
try
{
$this
->
tnef
=
$tnef
->
getMessage
();
$tnef
=
new
TnefStreamParser
(
$part
->
body
);
// No longer considered an attachment
$this
->
tnef
=
$tnef
->
getMessage
();
unset
(
$this
->
struct
->
parts
[
$i
]);
// No longer considered an attachment
unset
(
$this
->
struct
->
parts
[
$i
]);
}
catch
(
TnefException
$ex
)
{
// TNEF will remain an attachment
$this
->
notes
[]
=
'TNEF parsing exception: '
.
$ex
->
getMessage
();
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
include/tnef_decoder.php
+
21
−
10
View file @
ba637776
...
@@ -5,6 +5,11 @@
...
@@ -5,6 +5,11 @@
Parser library and data objects for Microsoft TNEF (Transport Neutral
Parser library and data objects for Microsoft TNEF (Transport Neutral
Encapsulation Format) encoded email attachments.
Encapsulation Format) encoded email attachments.
Jared Hancock <jared@osticket.com>
Peter Rotich <peter@osticket.com>
Copyright (c) 2006-2014 osTicket
http://www.osticket.com
This algorithm based on a similar project; however the original code did
This algorithm based on a similar project; however the original code did
not process the HTML body of the message, nor did it properly handle the
not process the HTML body of the message, nor did it properly handle the
Microsoft Unicode encoding found in the attributes.
Microsoft Unicode encoding found in the attributes.
...
@@ -25,11 +30,6 @@
...
@@ -25,11 +30,6 @@
* @author Michael Slusarz <slusarz@horde.org>
* @author Michael Slusarz <slusarz@horde.org>
* @package Horde_Compress
* @package Horde_Compress
Jared Hancock <jared@osticket.com>
Peter Rotich <peter@osticket.com>
Copyright (c) 2006-2013 osTicket
http://www.osticket.com
Released under the GNU General Public License WITHOUT ANY WARRANTY.
Released under the GNU General Public License WITHOUT ANY WARRANTY.
See LICENSE.TXT for details.
See LICENSE.TXT for details.
...
@@ -52,7 +52,14 @@ class TnefStreamReader implements Iterator {
...
@@ -52,7 +52,14 @@ class TnefStreamReader implements Iterator {
var
$streams
=
array
();
var
$streams
=
array
();
var
$current
=
true
;
var
$current
=
true
;
function
__construct
(
$stream
)
{
var
$options
=
array
(
'checksum'
=>
true
,
);
function
__construct
(
$stream
,
$options
=
array
())
{
if
(
is_array
(
$options
))
$this
->
options
+=
$options
;
$this
->
push
(
$stream
);
$this
->
push
(
$stream
);
// Read header
// Read header
...
@@ -102,11 +109,12 @@ class TnefStreamReader implements Iterator {
...
@@ -102,11 +109,12 @@ class TnefStreamReader implements Iterator {
return
$value
;
return
$value
;
}
}
function
check
(
$block
)
{
function
check
(
$block
)
{
$bytes
=
unpack
(
'*bb'
,
$block
[
'data'
]);
$sum
=
0
;
$sum
=
array_sum
(
$bytes
);
for
(
$i
=
0
,
$k
=
strlen
(
$block
[
'data'
]);
$i
<
$k
;
$i
++
)
return
$block
[
'checksum'
]
==
(
$sum
%
65535
);
$sum
+=
ord
(
$block
[
'data'
][
$i
]);
if
(
$block
[
'checksum'
]
!=
(
$sum
%
65536
))
throw
new
TnefException
(
'Corrupted block. Invalid checksum'
);
}
}
function
next
()
{
function
next
()
{
...
@@ -122,6 +130,9 @@ class TnefStreamReader implements Iterator {
...
@@ -122,6 +130,9 @@ class TnefStreamReader implements Iterator {
'data'
=>
$this
->
_getx
(
$length
),
'data'
=>
$this
->
_getx
(
$length
),
'checksum'
=>
$this
->
_geti
(
16
)
'checksum'
=>
$this
->
_geti
(
16
)
);
);
if
(
$this
->
options
[
'checksum'
])
$this
->
check
(
$this
->
current
);
}
}
function
current
()
{
function
current
()
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment