summaryrefslogtreecommitdiffstats
path: root/extensions/browser/computed_hashes.h
diff options
context:
space:
mode:
authorasargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-06 09:13:39 +0000
committerasargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-06 09:13:39 +0000
commitde00aeb7ef0858134cd747d2deada31fd12f2d86 (patch)
tree1a59298b2789c1345d4c069759e8e73674ee57d2 /extensions/browser/computed_hashes.h
parent75e9e84157cd914fcc8391a2c4ccefdddd17d426 (diff)
downloadchromium_src-de00aeb7ef0858134cd747d2deada31fd12f2d86.zip
chromium_src-de00aeb7ef0858134cd747d2deada31fd12f2d86.tar.gz
chromium_src-de00aeb7ef0858134cd747d2deada31fd12f2d86.tar.bz2
Fix for 0-length file problem in extension content verification
The problem is that we were generating zero hashes when there were no input bytes, when we should have generated one. To make this fix a little easier to test, I moved the code for generating hashes of content into a utility funciton in computed_hashes.{h,cc}. Also, in order to fix things for any profiles that might have incorrect computed_hashes.json files, I changed the format of it to add the notion of a version. When the format or version isn't recognized, the code will return an error from the Init function, and then the code that uses it elsewhere in the content verification code will automatically try to recreate it. BUG=399251 Review URL: https://codereview.chromium.org/436563004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287740 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions/browser/computed_hashes.h')
-rw-r--r--extensions/browser/computed_hashes.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/extensions/browser/computed_hashes.h b/extensions/browser/computed_hashes.h
index c68175c..c5e2052 100644
--- a/extensions/browser/computed_hashes.h
+++ b/extensions/browser/computed_hashes.h
@@ -9,10 +9,11 @@
#include <string>
#include <vector>
-#include "base/values.h"
+#include "base/memory/scoped_ptr.h"
namespace base {
class FilePath;
+class ListValue;
}
namespace extensions {
@@ -54,9 +55,16 @@ class ComputedHashes {
bool WriteToFile(const base::FilePath& path);
private:
- // The top-level object that will be serialized as JSON.
- base::ListValue file_list_;
+ // Each element of this list contains the path and block hashes for one
+ // file.
+ scoped_ptr<base::ListValue> file_list_;
};
+
+ // Computes the SHA256 hash of each |block_size| chunk in |contents|, placing
+ // the results into |hashes|.
+ static void ComputeHashesForContent(const std::string& contents,
+ size_t block_size,
+ std::vector<std::string>* hashes);
};
} // namespace extensions