Skip to content

Prevent signed integer overflow in RcDecideTargetBitsTimestamp - #4042

Open
kalt2212 wants to merge 1 commit into
cisco:masterfrom
kalt2212:patch/rc-timestamp-targetbits-overflow
Open

kalt2212 wants to merge 1 commit into
cisco:masterfrom
kalt2212:patch/rc-timestamp-targetbits-overflow

Conversation

@kalt2212

Copy link
Copy Markdown
Contributor

RcDecideTargetBitsTimestamp multiplies iTlayerWeight by kiGopBits in int32 arithmetic. iTlayerWeight goes up to 2000, so at 30 Mbps and 25 fps the product hits 2.4e9, past INT32_MAX.

A UBSan build of the encoder flags it right away: signed integer overflow at ratectl.cpp:643. The #3982 fix widened the sibling functions but missed this one.

This patch widens the computation to 64 bits, using the same WELS_DIV_ROUND64 approach as #3982.

@naunglinthuaung-creator naunglinthuaung-creator left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

codec/encoder/core/src/ratectl.cpp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants