ddiakopoulos / tinyply

:earth_africa: C++11 ply 3d mesh format importer & exporter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tinyply 2.0 crashes on malformed file

maruncz opened this issue · comments

Hi

i created this corrupted ply file
ply
format ascii 1.0
element vertex 16
property float x
property float y
property float z
.13043 0 255 0 0
10 7 0 255 0 0
10.9091 10 0 255 0 0
9.88235 9.05882 0 255 0 0
12 8 0 255 0 0
12 10 0 255 0 0
3 12 13 14
3 12 14 15
3 8 9 10
3 8 10 11
3 4 5 6
3 4 6 7
3 0 1 2
3 0 2 3

each vertex has aditional properties

but tinyply 2.0 will silently load this file and i get this ((1,1,1,1) color, (0,0,0) normal and 0 scalar are default if not fund)
vertices:
pos: vec3(10.000000, 7.000000, 0.000000) color: vec4(1.000000, 1.000000, 1.000000, 1.000000) normal: vec3(0.000000, 0.000000, 0.000000) scalar: 0
pos: vec3(255.000000, 0.000000, 0.000000) color: vec4(1.000000, 1.000000, 1.000000, 1.000000) normal: vec3(0.000000, 0.000000, 0.000000) scalar: 0
pos: vec3(10.909100, 10.000000, 0.000000) color: vec4(1.000000, 1.000000, 1.000000, 1.000000) normal: vec3(0.000000, 0.000000, 0.000000) scalar: 0
pos: vec3(255.000000, 0.000000, 0.000000) color: vec4(1.000000, 1.000000, 1.000000, 1.000000) normal: vec3(0.000000, 0.000000, 0.000000) scalar: 0
pos: vec3(9.882350, 9.058820, 0.000000) color: vec4(1.000000, 1.000000, 1.000000, 1.000000) normal: vec3(0.000000, 0.000000, 0.000000) scalar: 0
pos: vec3(255.000000, 0.000000, 0.000000) color: vec4(1.000000, 1.000000, 1.000000, 1.000000) normal: vec3(0.000000, 0.000000, 0.000000) scalar: 0
pos: vec3(12.000000, 8.000000, 0.000000) color: vec4(1.000000, 1.000000, 1.000000, 1.000000) normal: vec3(0.000000, 0.000000, 0.000000) scalar: 0
pos: vec3(255.000000, 0.000000, 0.000000) color: vec4(1.000000, 1.000000, 1.000000, 1.000000) normal: vec3(0.000000, 0.000000, 0.000000) scalar: 0
pos: vec3(12.000000, 10.000000, 0.000000) color: vec4(1.000000, 1.000000, 1.000000, 1.000000) normal: vec3(0.000000, 0.000000, 0.000000) scalar: 0
pos: vec3(255.000000, 0.000000, 0.000000) color: vec4(1.000000, 1.000000, 1.000000, 1.000000) normal: vec3(0.000000, 0.000000, 0.000000) scalar: 0
pos: vec3(3.000000, 12.000000, 13.000000) color: vec4(1.000000, 1.000000, 1.000000, 1.000000) normal: vec3(0.000000, 0.000000, 0.000000) scalar: 0
pos: vec3(14.000000, 3.000000, 12.000000) color: vec4(1.000000, 1.000000, 1.000000, 1.000000) normal: vec3(0.000000, 0.000000, 0.000000) scalar: 0
pos: vec3(14.000000, 15.000000, 3.000000) color: vec4(1.000000, 1.000000, 1.000000, 1.000000) normal: vec3(0.000000, 0.000000, 0.000000) scalar: 0
pos: vec3(8.000000, 9.000000, 10.000000) color: vec4(1.000000, 1.000000, 1.000000, 1.000000) normal: vec3(0.000000, 0.000000, 0.000000) scalar: 0
pos: vec3(3.000000, 8.000000, 10.000000) color: vec4(1.000000, 1.000000, 1.000000, 1.000000) normal: vec3(0.000000, 0.000000, 0.000000) scalar: 0
pos: vec3(11.000000, 3.000000, 4.000000) color: vec4(1.000000, 1.000000, 1.000000, 1.000000) normal: vec3(0.000000, 0.000000, 0.000000) scalar: 0
faces:

as you can see those aditional properties gets loaded into position vector

tinyply 2.3.2 will also silently load this file and have mismatched properties (a malformed header/payload mismatch is nearly impossible to correct for), but this file shouldn't crash anymore.