]> git.lyx.org Git - features.git/commitdiff
Two places where coverity urges us to limit string length
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 24 Mar 2017 14:25:42 +0000 (15:25 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 24 Mar 2017 14:27:22 +0000 (15:27 +0100)
These two issues make sense, but there are probably others.

src/insets/InsetTabular.cpp
src/mathed/MathFactory.cpp

index 88817357c16c663aa91c5aeef8ef3777ec457c80..1fc492eea03262b9fa70e70ae8bff9dcbf2205cb 100644 (file)
@@ -66,6 +66,7 @@
 #include "support/unique_ptr.h"
 
 #include <cstring>
+#include <iomanip>
 #include <iostream>
 #include <limits>
 #include <sstream>
@@ -5356,6 +5357,8 @@ void InsetTabular::tabularFeatures(Cursor & cur, string const & argument)
        cur.recordUndoInset(this);
 
        istringstream is(argument);
+       // limit the size of strings we read to avoid memory problems
+       is >> setw(65636);
        string s;
        // Safe guard.
        size_t safe_guard = 0;
index 2cd045b0ccb7930ce32f0a88e94a16083dba433d..79ae676fc39b3ddc3d583149fd7d306f41e6d568 100644 (file)
@@ -149,6 +149,8 @@ void initSymbols()
        }
 
        ifstream fs(filename.toFilesystemEncoding().c_str());
+       // limit the size of strings we read to avoid memory problems
+       fs >> setw(65636);
        string line;
        bool skip = false;
        while (getline(fs, line)) {
@@ -160,6 +162,8 @@ void initSymbols()
                // special case of iffont/else/endif
                if (line.size() >= 7 && line.substr(0, 6) == "iffont") {
                        istringstream is(line);
+                       // limit the size of strings we read to avoid memory problems
+                       is >> setw(65636);
                        string tmp;
                        is >> tmp;
                        is >> tmp;