termux-packages/packages/openscad/CVE-2020-28599.patch

63 lines
2.1 KiB
Diff

https://src.fedoraproject.org/rpms/openscad/c/d6b5571d1bb9533e77463d09b017d1903504c4a9
https://github.com/openscad/openscad/commit/f6451264c04ab5fd1f3c544486c5dbe3e63e9536
--- a/src/import_stl.cc
+++ b/src/import_stl.cc
@@ -88,12 +88,17 @@ PolySet *import_stl(const std::string &filename, const Location &loc)
f.read(data, 5);
if (!binary && !f.eof() && f.good() && !memcmp(data, "solid", 5)) {
int i = 0;
+ int lineno = 1;
double vdata[3][3];
std::string line;
std::getline(f, line);
while (!f.eof()) {
+ lineno++;
std::getline(f, line);
boost::trim(line);
+ if (line.length() == 0) {
+ continue;
+ }
if (boost::regex_search(line, ex_sfe)) {
continue;
}
@@ -101,23 +106,27 @@ PolySet *import_stl(const std::string &filename, const Location &loc)
i = 0;
continue;
}
+ if (i >= 3) {
+ PRINTB("ERROR: STL line %1$s, extra vertex line '%2$s' importing file '%3$s'", lineno % line % filename);
+ delete p;
+ return new PolySet(3);
+ }
boost::smatch results;
if (boost::regex_search(line, results, ex_vertices)) {
try {
for (int v=0;v<3;v++) {
vdata[i][v] = boost::lexical_cast<double>(results[v+1]);
}
- }
- catch (const boost::bad_lexical_cast &blc) {
- PRINTB("WARNING: Can't parse vertex line '%s', import() at line %d", line % loc.firstLine());
- i = 10;
- continue;
- }
- if (++i == 3) {
- p->append_poly();
- p->append_vertex(vdata[0][0], vdata[0][1], vdata[0][2]);
- p->append_vertex(vdata[1][0], vdata[1][1], vdata[1][2]);
- p->append_vertex(vdata[2][0], vdata[2][1], vdata[2][2]);
+ if (++i == 3) {
+ p->append_poly();
+ p->append_vertex(vdata[0][0], vdata[0][1], vdata[0][2]);
+ p->append_vertex(vdata[1][0], vdata[1][1], vdata[1][2]);
+ p->append_vertex(vdata[2][0], vdata[2][1], vdata[2][2]);
+ }
+ } catch (const boost::bad_lexical_cast& blc) {
+ PRINTB("ERROR: STL line %1$s, can't parse vertex line '%2$s' importing file '%3$s'", lineno % line % filename);
+ delete p;
+ return new PolySet(3);
}
}
}