mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-14 04:36:10 +08:00
Abort loading if the file size is larger than the reported # of facets in the file header.
This commit is contained in:
parent
f9f8be46e3
commit
66df176447
@ -131,6 +131,12 @@ stl_count_facets(stl_file *stl, const char *file) {
|
|||||||
if((!fread(&header_num_facets, sizeof(int), 1, stl->fp)) || (num_facets != header_num_facets)) {
|
if((!fread(&header_num_facets, sizeof(int), 1, stl->fp)) || (num_facets != header_num_facets)) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Warning: File size doesn't match number of facets in the header\n");
|
"Warning: File size doesn't match number of facets in the header\n");
|
||||||
|
|
||||||
|
if(num_facets > header_num_facets) {
|
||||||
|
// this file is garbage.
|
||||||
|
stl->error = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Otherwise, if the .STL file is ASCII, then do the following */
|
/* Otherwise, if the .STL file is ASCII, then do the following */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user