From 4ea0fd6af41beffc3eea1efcf8a0427a9d122b9c Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Fri, 24 Mar 2017 15:25:42 +0100 Subject: [PATCH] Two places where coverity urges us to limit string length These two issues make sense, but there are probably others. --- src/insets/InsetTabular.cpp | 3 +++ src/mathed/MathFactory.cpp | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 88817357c1..1fc492eea0 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -66,6 +66,7 @@ #include "support/unique_ptr.h" #include +#include #include #include #include @@ -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; diff --git a/src/mathed/MathFactory.cpp b/src/mathed/MathFactory.cpp index 2cd045b0cc..79ae676fc3 100644 --- a/src/mathed/MathFactory.cpp +++ b/src/mathed/MathFactory.cpp @@ -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; -- 2.39.2