Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libavcdec: Fix integer overflow issue in ui_max_frame_num #108

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions decoder/ih264d_dpb_mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ WORD32 ih264d_ref_idx_reordering(dec_struct_t *ps_dec, UWORD8 uc_lx)
dpb_manager_t *ps_dpb_mgr = ps_dec->ps_dpb_mgr;
UWORD16 u4_cur_pic_num = ps_dec->ps_cur_slice->u2_frame_num;
/*< Maximum Picture Number Minus 1 */
UWORD16 ui_max_frame_num =
UWORD32 ui_max_frame_num =
ps_dec->ps_cur_sps->u2_u4_max_pic_num_minus1 + 1;

WORD32 i, count = 0;
Expand Down Expand Up @@ -776,7 +776,7 @@ WORD32 ih264d_ref_idx_reordering(dec_struct_t *ps_dec, UWORD8 uc_lx)
{
// diffPicNum is +ve
i_temp = (WORD32)u2_pred_frame_num + (WORD32)ui_nextUev;
if(i_temp >= ui_max_frame_num)
if(i_temp >= (WORD32)ui_max_frame_num)
i_temp -= ui_max_frame_num;
}
/* Find the dpb with the matching picNum (picNum==frameNum for framePic) */
Expand Down
6 changes: 3 additions & 3 deletions decoder/ih264d_parse_headers.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ WORD32 ih264d_parse_sps(dec_struct_t *ps_dec, dec_bit_stream_t *ps_bitstrm)
UWORD8 i;
dec_seq_params_t *ps_seq = NULL;
UWORD8 u1_profile_idc, u1_level_idc, u1_seq_parameter_set_id, u1_mb_aff_flag = 0;
UWORD16 i2_max_frm_num;
UWORD32 u4_max_frm_num;
UWORD32 *pu4_bitstrm_buf = ps_bitstrm->pu4_buffer;
UWORD32 *pu4_bitstrm_ofst = &ps_bitstrm->u4_ofst;
UWORD8 u1_frm, uc_constraint_set0_flag, uc_constraint_set1_flag;
Expand Down Expand Up @@ -794,8 +794,8 @@ WORD32 ih264d_parse_sps(dec_struct_t *ps_dec, dec_bit_stream_t *ps_bitstrm)
COPYTHECONTEXT("SPS: log2_max_frame_num_minus4",
(ps_seq->u1_bits_in_frm_num - 4));

i2_max_frm_num = (1 << (ps_seq->u1_bits_in_frm_num));
ps_seq->u2_u4_max_pic_num_minus1 = i2_max_frm_num - 1;
u4_max_frm_num = (1 << (ps_seq->u1_bits_in_frm_num));
ps_seq->u2_u4_max_pic_num_minus1 = u4_max_frm_num - 1;
/*--------------------------------------------------------------------*/
/* Decode picture order count and related values */
/*--------------------------------------------------------------------*/
Expand Down
2 changes: 1 addition & 1 deletion decoder/ih264d_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ typedef struct
UWORD8 u1_arbitrary_slice_order_allowed_flag;
UWORD8 u1_redundant_slices_allowed_flag;
UWORD8 u1_bits_in_frm_num; /** Number of bits in frame num */
UWORD16 u2_u4_max_pic_num_minus1; /** Maximum frame num minus 1 */
UWORD32 u2_u4_max_pic_num_minus1; /** Maximum frame num minus 1 */
UWORD8 u1_pic_order_cnt_type; /** 0 - 2 indicates the method to code picture order count */
UWORD8 u1_log2_max_pic_order_cnt_lsb_minus;
WORD32 i4_max_pic_order_cntLsb;
Expand Down
Loading