Skip to content
Snippets Groups Projects
Commit b4923aaa authored by Guillaume Roguez's avatar Guillaume Roguez Committed by gerrit2
Browse files

fileutils: fix bad numeric comparison in loadFile

The file size was wrongly checked in loadFile,
giving a always true comparaison.

(issue detected by coverity.com analysis)

Change-Id: I2aa4f5c737df3a3b815caebc97bdc3820df8b534
Tuleap: #909
parent fe12fa8a
No related branches found
No related tags found
No related merge requests found
......@@ -259,8 +259,8 @@ loadFile(const std::string& path)
if (!file)
throw std::runtime_error("Can't read file: "+path);
file.seekg(0, std::ios::end);
std::streamsize size = file.tellg();
if ((unsigned)size > std::numeric_limits<unsigned>::max())
auto size = file.tellg();
if (size > std::numeric_limits<unsigned>::max())
throw std::runtime_error("File is too big: "+path);
buffer.resize(size);
file.seekg(0, std::ios::beg);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment