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

Side by Side Diff: ui/display/util/edid_parser.cc

Issue 2249973006: ui: Fix potential out-of-bounds array access in EDID parser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add header byte to size check Created 4 years, 4 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/display/util/edid_parser.h" 5 #include "ui/display/util/edid_parser.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 228
229 for (size_t data_offset = extension_offset + kDataBlockOffset; 229 for (size_t data_offset = extension_offset + kDataBlockOffset;
230 data_offset < extension_offset + timing_descriptors_start;) { 230 data_offset < extension_offset + timing_descriptors_start;) {
231 // A data block is encoded as: 231 // A data block is encoded as:
232 // - byte 1 high 3 bits: tag. '07' for extended tags. 232 // - byte 1 high 3 bits: tag. '07' for extended tags.
233 // - byte 1 remaining bits: the length of data block. 233 // - byte 1 remaining bits: the length of data block.
234 // - byte 2: the extended tag. '0' for video capability. 234 // - byte 2: the extended tag. '0' for video capability.
235 // - byte 3: the capability. 235 // - byte 3: the capability.
236 unsigned char tag = edid[data_offset] >> 5; 236 unsigned char tag = edid[data_offset] >> 5;
237 unsigned char payload_length = edid[data_offset] & 0x1f; 237 unsigned char payload_length = edid[data_offset] & 0x1f;
238 if (data_offset + payload_length > edid.size()) 238 if (data_offset + payload_length + 1 > edid.size())
239 break; 239 break;
240 240
241 if (tag != kExtendedTag || payload_length < 2 || 241 if (tag != kExtendedTag || payload_length < 2 ||
242 edid[data_offset + 1] != kExtendedVideoCapabilityTag) { 242 edid[data_offset + 1] != kExtendedVideoCapabilityTag) {
243 data_offset += payload_length + 1; 243 data_offset += payload_length + 1;
244 continue; 244 continue;
245 } 245 }
246 246
247 // The difference between preferred, IT, and CE video formats 247 // The difference between preferred, IT, and CE video formats
248 // doesn't matter. Sets |flag| to true if any of these flags are true. 248 // doesn't matter. Sets |flag| to true if any of these flags are true.
249 if ((edid[data_offset + 2] & (1 << kPTOverscan)) || 249 if ((edid[data_offset + 2] & (1 << kPTOverscan)) ||
250 (edid[data_offset + 2] & (1 << kITOverscan)) || 250 (edid[data_offset + 2] & (1 << kITOverscan)) ||
251 (edid[data_offset + 2] & (1 << kCEOverscan))) { 251 (edid[data_offset + 2] & (1 << kCEOverscan))) {
252 *flag = true; 252 *flag = true;
253 } else { 253 } else {
254 *flag = false; 254 *flag = false;
255 } 255 }
256 return true; 256 return true;
257 } 257 }
258 } 258 }
259 259
260 return false; 260 return false;
261 } 261 }
262 262
263 } // namespace ui 263 } // namespace ui
OLDNEW
« 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