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

Unified 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 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: core/fxcodec/codec/fx_codec_tiff.cpp
diff --git a/core/fxcodec/codec/fx_codec_tiff.cpp b/core/fxcodec/codec/fx_codec_tiff.cpp
index c4c745587f31fd7fa3b215f49e3a17f360000746..8046f1cc39c50de0a7c8fd1717d9ee70e2dc99aa 100644
--- a/core/fxcodec/codec/fx_codec_tiff.cpp
+++ b/core/fxcodec/codec/fx_codec_tiff.cpp
@@ -447,7 +447,11 @@ bool CCodec_TiffContext::Decode(CFX_DIBitmap* pDIBitmap) {
uint16_t bps = 0;
TIFFGetField(m_tif_ctx, TIFFTAG_SAMPLESPERPIXEL, &spp);
TIFFGetField(m_tif_ctx, TIFFTAG_BITSPERSAMPLE, &bps);
- uint32_t bpp = bps * spp;
+ FX_SAFE_UINT32 safe_bpp = bps;
+ safe_bpp *= spp;
+ if (!safe_bpp.IsValid())
+ return false;
+ uint32_t bpp = safe_bpp.ValueOrDie();
if (bpp == 1)
return Decode1bppRGB(pDIBitmap, height, width, bps, spp);
if (bpp <= 8)
« 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