Skip to content

Commit

Permalink
Fix OOB issue in nal unit parsing
Browse files Browse the repository at this point in the history
Bug: 37712181
Test: ran patched against POC on nyc-mr2
Change-Id: I5408b3afd898db99265f94573d1163ef83c9b99c
(cherry picked from commit 62ebc3276199bef53c4b87cfcd8c8586af255fee)
  • Loading branch information
naveenkumarponnusamy authored and andi34 committed Aug 26, 2017
1 parent 0d2bd8b commit 2cd07b5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions decoder/ihevcd_nal.c
Expand Up @@ -114,7 +114,8 @@ WORD32 ihevcd_nal_search_start_code(UWORD8 *pu1_buf, WORD32 bytes_remaining)
}

zero_byte_cnt++;
if((pu1_buf[ofst + 1] == START_CODE_PREFIX_BYTE) &&
if((ofst < (bytes_remaining - 1)) &&
(pu1_buf[ofst + 1] == START_CODE_PREFIX_BYTE) &&
(zero_byte_cnt >= NUM_ZEROS_BEFORE_START_CODE))
{
/* Found the start code */
Expand All @@ -123,7 +124,7 @@ WORD32 ihevcd_nal_search_start_code(UWORD8 *pu1_buf, WORD32 bytes_remaining)
break;
}
}
if(0 == start_code_found)
if((0 == start_code_found) && (ofst < bytes_remaining))
{
if((START_CODE_PREFIX_BYTE == pu1_buf[ofst]) &&
(zero_byte_cnt >= NUM_ZEROS_BEFORE_START_CODE))
Expand Down Expand Up @@ -231,7 +232,7 @@ IHEVCD_ERROR_T ihevcd_nal_remv_emuln_bytes(UWORD8 *pu1_src,

}

if(0 == start_code_found)
if((0 == start_code_found) && (src_cnt < bytes_remaining))
{
u1_src = pu1_src[src_cnt++];
if(zero_byte_cnt >= NUM_ZEROS_BEFORE_START_CODE)
Expand Down

0 comments on commit 2cd07b5

Please sign in to comment.