Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(493)

Unified Diff: chrome/browser/resources/file_manager/js/exif_parser.js

Issue 8771037: File Browser Exif parser: support more exotic format variants (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: EOF check for corrupt files Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/file_manager/js/exif_parser.js
diff --git a/chrome/browser/resources/file_manager/js/exif_parser.js b/chrome/browser/resources/file_manager/js/exif_parser.js
index 7003153f3bfbcc05adbc4bd9fbd6e54468286b86..2627f65924003b948f3b1f1daea1b6d677061907 100644
--- a/chrome/browser/resources/file_manager/js/exif_parser.js
+++ b/chrome/browser/resources/file_manager/js/exif_parser.js
@@ -85,14 +85,20 @@ ExifParser.prototype.parseSlice = function(
var nextSectionStart = br.tell() + markLength;
if (!br.canRead(markLength)) {
// Get the entire section.
+ if (filePos + br.tell() + markLength > file.size) {
+ throw new Error(
+ 'Invalid section length @' + (filePos + br.tell() - 2));
+ }
reread(-4, markLength + 4);
return;
}
if (mark == EXIF_MARK_EXIF) {
this.parseExifSection(metadata, buf, br);
- } else if (mark == EXIF_MARK_SOF) {
+ } else if ((mark & ~0xF) == EXIF_MARK_SOF) {
// The most reliable size information is encoded in the SOF section.
+ // There are 16 variants of the SOF format distinguished by the last
+ // hex digit of the mark, but the part we want is always the same.
br.seek(1, ByteReader.SEEK_CUR); // Skip the precision byte.
var height = br.readScalar(2);
var width = br.readScalar(2);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698