Home | History | Annotate | Download | only in libopenjpeg20
      1 diff --git a/third_party/libopenjpeg20/README.pdfium b/third_party/libopenjpeg20/README.pdfium
      2 index a9e289d..b1012af 100644
      3 --- a/third_party/libopenjpeg20/README.pdfium
      4 +++ b/third_party/libopenjpeg20/README.pdfium
      5 @@ -28,4 +28,5 @@ Local Modifications:
      6  0016-read_SQcd_SQcc_overflow.patch: Prevent a buffer overflow in opj_j2k_read_SQcd_SQcc.
      7  0017-tcd_init_tile.patch: Prevent integer overflows during calculation of |l_nb_precinct_size|.
      8  0018-tcd_get_decoded_tile_size.patch: Fix an integer overflow in opj_tcd_get_decoded_tile_size.
      9 +0019-tcd_init_tile.patch: Prevent integer overflows during calculation of |l_nb_code_blocks_size|.
     10  TODO(thestig): List all the other patches.
     11 diff --git a/third_party/libopenjpeg20/tcd.c b/third_party/libopenjpeg20/tcd.c
     12 index cd1c439..9270efe 100644
     13 --- a/third_party/libopenjpeg20/tcd.c
     14 +++ b/third_party/libopenjpeg20/tcd.c
     15 @@ -939,8 +939,15 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
     16  					l_current_precinct->cw = (OPJ_UINT32)((brcblkxend - tlcblkxstart) >> cblkwidthexpn);
     17  					l_current_precinct->ch = (OPJ_UINT32)((brcblkyend - tlcblkystart) >> cblkheightexpn);
     18  					
     19 +					if (l_current_precinct->cw && ((OPJ_UINT32)-1) / l_current_precinct->cw < l_current_precinct->ch) {
     20 +						return OPJ_FALSE;
     21 +					}
     22  					l_nb_code_blocks = l_current_precinct->cw * l_current_precinct->ch;
     23  					/*fprintf(stderr, "\t\t\t\t precinct_cw = %d x recinct_ch = %d\n",l_current_precinct->cw, l_current_precinct->ch);      */
     24 +					
     25 +					if (((OPJ_UINT32)-1) / (OPJ_UINT32)sizeof_block < l_nb_code_blocks) {
     26 +						return OPJ_FALSE;
     27 +					}
     28  					l_nb_code_blocks_size = l_nb_code_blocks * (OPJ_UINT32)sizeof_block;
     29  					
     30  					if (! l_current_precinct->cblks.blocks) {
     31