summaryrefslogtreecommitdiff
path: root/core/src/fxcodec
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2014-08-26 16:35:12 -0700
committerTom Sepez <tsepez@chromium.org>2014-08-26 16:35:12 -0700
commit96f87863739e2e6ebc76c6656fbb1101bdfc1378 (patch)
tree3078bd2a75c618bd3fe1d4433dd0e5a284839161 /core/src/fxcodec
parent02e6ca4c4fc94f72fa7aac326234dfd8a9f61d23 (diff)
downloadpdfium-96f87863739e2e6ebc76c6656fbb1101bdfc1378.tar.xz
Bounds check before fixed-size memcmp() in CJPX_Decoder::Init().
BUG=407476 R=jun_fang@foxitsoftware.com Review URL: https://codereview.chromium.org/489703004
Diffstat (limited to 'core/src/fxcodec')
-rw-r--r--core/src/fxcodec/codec/fx_codec_jpx_opj.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
index 4494244410..5ae75557cd 100644
--- a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
+++ b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
@@ -581,7 +581,10 @@ CJPX_Decoder::~CJPX_Decoder()
}
FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, int src_size)
{
- opj_dparameters_t parameters;
+ static const unsigned char szJP2Header[] = { 0x00, 0x00, 0x00, 0x0c, 0x6a, 0x50, 0x20, 0x20, 0x0d, 0x0a, 0x87, 0x0a };
+ if (!src_data || src_size < sizeof(szJP2Header)) {
+ return FALSE;
+ }
image = NULL;
m_SrcData = src_data;
m_SrcSize = src_size;
@@ -593,10 +596,11 @@ FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, int src_size)
if (l_stream == NULL) {
return FALSE;
}
+ opj_dparameters_t parameters;
opj_set_default_decoder_parameters(&parameters);
parameters.decod_format = 0;
parameters.cod_format = 3;
- if(FXSYS_memcmp32(m_SrcData, "\x00\x00\x00\x0c\x6a\x50\x20\x20\x0d\x0a\x87\x0a", 12) == 0) {
+ if(FXSYS_memcmp32(m_SrcData, szJP2Header, sizeof(szJP2Header)) == 0) {
l_codec = opj_create_decompress(OPJ_CODEC_JP2);
parameters.decod_format = 1;
} else {