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

Side by Side Diff: core/fxcodec/codec/fx_codec_tiff.cpp

Issue 2520253003: Multiply safely in CCodec_TiffContext::Decode (Closed)
Patch Set: Created 4 years, 1 month 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 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium 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 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "core/fxcodec/codec/codec_int.h" 9 #include "core/fxcodec/codec/codec_int.h"
10 #include "core/fxcodec/fx_codec.h" 10 #include "core/fxcodec/fx_codec.h"
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 uint8_t* row_buf = (uint8_t*)pDIBitmap->GetScanline(row); 440 uint8_t* row_buf = (uint8_t*)pDIBitmap->GetScanline(row);
441 TiffBGRA2RGBA(row_buf, img_wid, 4); 441 TiffBGRA2RGBA(row_buf, img_wid, 4);
442 } 442 }
443 return true; 443 return true;
444 } 444 }
445 } 445 }
446 uint16_t spp = 0; 446 uint16_t spp = 0;
447 uint16_t bps = 0; 447 uint16_t bps = 0;
448 TIFFGetField(m_tif_ctx, TIFFTAG_SAMPLESPERPIXEL, &spp); 448 TIFFGetField(m_tif_ctx, TIFFTAG_SAMPLESPERPIXEL, &spp);
449 TIFFGetField(m_tif_ctx, TIFFTAG_BITSPERSAMPLE, &bps); 449 TIFFGetField(m_tif_ctx, TIFFTAG_BITSPERSAMPLE, &bps);
450 uint32_t bpp = bps * spp; 450 FX_SAFE_UINT32 safe_bpp = bps;
451 safe_bpp *= spp;
452 if (!safe_bpp.IsValid())
453 return false;
454 uint32_t bpp = safe_bpp.ValueOrDie();
451 if (bpp == 1) 455 if (bpp == 1)
452 return Decode1bppRGB(pDIBitmap, height, width, bps, spp); 456 return Decode1bppRGB(pDIBitmap, height, width, bps, spp);
453 if (bpp <= 8) 457 if (bpp <= 8)
454 return Decode8bppRGB(pDIBitmap, height, width, bps, spp); 458 return Decode8bppRGB(pDIBitmap, height, width, bps, spp);
455 if (bpp <= 24) 459 if (bpp <= 24)
456 return Decode24bppRGB(pDIBitmap, height, width, bps, spp); 460 return Decode24bppRGB(pDIBitmap, height, width, bps, spp);
457 return false; 461 return false;
458 } 462 }
459 463
460 CCodec_TiffContext* CCodec_TiffModule::CreateDecoder( 464 CCodec_TiffContext* CCodec_TiffModule::CreateDecoder(
(...skipping 17 matching lines...) Expand all
478 } 482 }
479 483
480 bool CCodec_TiffModule::Decode(CCodec_TiffContext* ctx, 484 bool CCodec_TiffModule::Decode(CCodec_TiffContext* ctx,
481 class CFX_DIBitmap* pDIBitmap) { 485 class CFX_DIBitmap* pDIBitmap) {
482 return ctx->Decode(pDIBitmap); 486 return ctx->Decode(pDIBitmap);
483 } 487 }
484 488
485 void CCodec_TiffModule::DestroyDecoder(CCodec_TiffContext* ctx) { 489 void CCodec_TiffModule::DestroyDecoder(CCodec_TiffContext* ctx) {
486 delete ctx; 490 delete ctx;
487 } 491 }
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