Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
OpenMesh
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
13
Issues
13
List
Boards
Labels
Service Desk
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenMesh
OpenMesh
Commits
c68c630e
Commit
c68c630e
authored
Jun 18, 2018
by
Jan Möbius
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent endless loop in PLY reader when unknown property types are read.
parent
aa98be12
Pipeline
#7218
passed with stage
in 66 minutes and 1 second
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
222 additions
and
166 deletions
+222
-166
src/OpenMesh/Core/IO/reader/PLYReader.cc
src/OpenMesh/Core/IO/reader/PLYReader.cc
+168
-166
src/Unittests/unittests_read_write_PLY.cc
src/Unittests/unittests_read_write_PLY.cc
+54
-0
No files found.
src/OpenMesh/Core/IO/reader/PLYReader.cc
View file @
c68c630e
...
...
@@ -1240,13 +1240,15 @@ bool _PLYReader_::can_u_read(std::istream& _is) const {
if
(
listIndexType
==
"uint8"
)
{
indexType
=
ValueTypeUINT8
;
}
else
if
(
listIndexType
==
"uint16"
)
{
indexType
=
ValueTypeUINT16
;
}
else
if
(
listIndexType
==
"uchar"
)
{
indexType
=
ValueTypeUCHAR
;
}
else
if
(
listIndexType
==
"int"
)
{
indexType
=
ValueTypeINT
;
}
else
{
omerr
()
<<
"Unsupported Index type for property list: "
<<
listIndexType
<<
std
::
endl
;
continu
e
;
return
fals
e
;
}
entryType
=
get_property_type
(
listEntryType
,
listEntryType
);
...
...
src/Unittests/unittests_read_write_PLY.cc
View file @
c68c630e
...
...
@@ -728,4 +728,58 @@ TEST_F(OpenMeshReadWritePLY, LoadSimpleBinaryPLYWithExtraElements) {
EXPECT_EQ
(
12u
,
mesh_
.
n_faces
())
<<
"The number of loaded faces is not correct!"
;
}
/*
* Ignore a file that does not contain vertices and faces
*/
TEST_F
(
OpenMeshReadWritePLY
,
IgnoreNonMeshPlyFile
)
{
mesh_
.
clear
();
std
::
stringstream
data
;
data
<<
"ply"
<<
"
\n
"
;
data
<<
"format binary_little_endian 1.0"
<<
"
\n
"
;
data
<<
"comment Image data"
<<
"
\n
"
;
data
<<
"element image 0"
<<
"
\n
"
;
data
<<
"property list uint16 uint16 row"
<<
"
\n
"
;
data
<<
"end_header"
<<
"
\n
"
;
OpenMesh
::
IO
::
Options
options
=
OpenMesh
::
IO
::
Options
::
Binary
;
bool
ok
=
OpenMesh
::
IO
::
read_mesh
(
mesh_
,
data
,
".ply"
,
options
);
EXPECT_TRUE
(
ok
)
<<
"This empty file should be readable without an error!"
;
EXPECT_EQ
(
0u
,
mesh_
.
n_vertices
())
<<
"The number of loaded vertices is not correct!"
;
EXPECT_EQ
(
0u
,
mesh_
.
n_edges
())
<<
"The number of loaded edges is not correct!"
;
EXPECT_EQ
(
0u
,
mesh_
.
n_faces
())
<<
"The number of loaded faces is not correct!"
;
}
/*
* Ignore a file that does not contain vertices and faces
*/
TEST_F
(
OpenMeshReadWritePLY
,
FailOnUnknownPropertyTypeForLists
)
{
mesh_
.
clear
();
std
::
stringstream
data
;
data
<<
"ply"
<<
"
\n
"
;
data
<<
"format binary_little_endian 1.0"
<<
"
\n
"
;
data
<<
"comment Image data"
<<
"
\n
"
;
data
<<
"element image 0"
<<
"
\n
"
;
data
<<
"property list blibb blubb row"
<<
"
\n
"
;
data
<<
"end_header"
<<
"
\n
"
;
OpenMesh
::
IO
::
Options
options
=
OpenMesh
::
IO
::
Options
::
Binary
;
bool
ok
=
OpenMesh
::
IO
::
read_mesh
(
mesh_
,
data
,
".ply"
,
options
);
EXPECT_FALSE
(
ok
)
<<
"This file should fail to read!"
;
EXPECT_EQ
(
0u
,
mesh_
.
n_vertices
())
<<
"The number of loaded vertices is not correct!"
;
EXPECT_EQ
(
0u
,
mesh_
.
n_edges
())
<<
"The number of loaded edges is not correct!"
;
EXPECT_EQ
(
0u
,
mesh_
.
n_faces
())
<<
"The number of loaded faces is not correct!"
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment