Make base::ReadFileToString() return false on I/O error.

It seems inconsistent that ReadFileToString() currently returns false when encountering a file open error but true upon file read error.  This CL forces the return value to false upon encountering any kind of error and documents this behaviour.

At that occasion, a test for path traversal prevention is added.

BUG=none

Review URL: https://codereview.chromium.org/254333002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@267507 0039d316-1c4b-4281-b951-d872f2087c98


CrOS-Libchrome-Original-Commit: 731daa1a55f46d844aeb6d5d0ffbb8242c39d7b9
diff --git a/base/file_util.cc b/base/file_util.cc
index c1bf50a..d11cd15 100644
--- a/base/file_util.cc
+++ b/base/file_util.cc
@@ -157,6 +157,7 @@
 
     size += len;
   }
+  read_status = read_status && !ferror(file);
   CloseFile(file);
 
   return read_status;