From b427f338186d4a8edabd9baf6b9b180b612d0893 Mon Sep 17 00:00:00 2001 From: He Junyan Date: Sat, 7 Sep 2024 10:26:22 +0800 Subject: [PATCH] h265bitwriter: Add check for data size to avoid overflow Part-of: --- .../gst-libs/gst/codecparsers/gsth265bitwriter.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265bitwriter.c b/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265bitwriter.c index a175a9c2b2..ae6acd8b22 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265bitwriter.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265bitwriter.c @@ -2237,6 +2237,7 @@ gst_h265_bit_writer_convert_to_nal (guint nal_prefix_size, GST_H265_BIT_WRITER_ERROR); g_return_val_if_fail (raw_data != NULL, GST_H265_BIT_WRITER_ERROR); g_return_val_if_fail (raw_size > 0, GST_H265_BIT_WRITER_ERROR); + g_return_val_if_fail (raw_size / 8 <= G_MAXUINT, GST_H265_BIT_WRITER_ERROR); g_return_val_if_fail (nal_data != NULL, GST_H265_BIT_WRITER_ERROR); g_return_val_if_fail (nal_size != NULL, GST_H265_BIT_WRITER_ERROR); g_return_val_if_fail (*nal_size > 0, GST_H265_BIT_WRITER_ERROR); @@ -2264,7 +2265,7 @@ gst_h265_bit_writer_convert_to_nal (guint nal_prefix_size, nal_writer_init (&nw, nal_prefix_size, packetized); - if (!nal_writer_put_bytes (&nw, raw_data, raw_size / 8)) + if (!nal_writer_put_bytes (&nw, raw_data, (guint) (raw_size / 8))) goto error; if (raw_size % 8) {