diff options
author | Georges Basile Stavracas Neto <georges.stavracas@gmail.com> | 2022-12-15 16:51:54 -0300 |
---|---|---|
committer | Robert Mader <robert.mader@collabora.com> | 2023-01-06 13:53:08 +0100 |
commit | eda3d5180a513337f338a25df5af491aea87a253 (patch) | |
tree | 5287225cc2e6ef4e330712c18456aaa3c53859ba /src | |
parent | 9113b78a3f3b25aee89d9b69bd639c1e4cb01e74 (diff) | |
download | mutter-eda3d5180a513337f338a25df5af491aea87a253.tar.gz |
screen-cast/src: Fix unsigned integer overflow
The fields of 'priv->video_format.max_framerate' are all of type
uint32_t. Multiplying by G_USEC_PER_SEC can overflow, and equally,
dividing a large numerical type by uint32_t can err too.
Since the variable holding the result is int64_t, cast all uint32_t
fields to int64_t before doing any maths on it.
Spotted while trying to investigating an issue with framerates on
HDMI screencasts.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2762>
(cherry picked from commit abfedcb0c351bbdbc64b397f4c3e7624f186a48e)
Diffstat (limited to 'src')
-rw-r--r-- | src/backends/meta-screen-cast-stream-src.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/backends/meta-screen-cast-stream-src.c b/src/backends/meta-screen-cast-stream-src.c index f0a89c925..05dcaa590 100644 --- a/src/backends/meta-screen-cast-stream-src.c +++ b/src/backends/meta-screen-cast-stream-src.c @@ -610,8 +610,8 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src, int64_t time_since_last_frame_us; min_interval_us = - ((G_USEC_PER_SEC * priv->video_format.max_framerate.denom) / - priv->video_format.max_framerate.num); + ((G_USEC_PER_SEC * ((int64_t) priv->video_format.max_framerate.denom)) / + ((int64_t) priv->video_format.max_framerate.num)); time_since_last_frame_us = now_us - priv->last_frame_timestamp_us; if (time_since_last_frame_us < min_interval_us) |