From 59abdba8809f80d53313e3c22d42c3069b6107c9 Mon Sep 17 00:00:00 2001
From: Salvatore Bonaccorso <carnil@debian.org>
Date: Fri, 13 Dec 2024 06:13:42 +0100
Subject: [PATCH 1/3] Import Debian changes 1.22.0-2+deb12u1

---
 debian/changelog                              |  7 +++
 ...integer-overflow-when-allocating-sys.patch | 48 +++++++++++++++++++
 debian/patches/series                         |  1 +
 3 files changed, 56 insertions(+)
 create mode 100644 debian/patches/allocator-Avoid-integer-overflow-when-allocating-sys.patch

diff --git a/debian/changelog b/debian/changelog
index 8ee08b8..41c6346 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+gstreamer1.0 (1.22.0-2+deb12u1) bookworm-security; urgency=high
+
+  * Non-maintainer upload by the Security Team.
+  * allocator: Avoid integer overflow when allocating sysmem (CVE-2024-47606)
+
+ -- Salvatore Bonaccorso <carnil@debian.org>  Fri, 13 Dec 2024 06:13:42 +0100
+
 gstreamer1.0 (1.22.0-2) unstable; urgency=medium
 
   * debian/rules: Set -Dauto_features=enabled
diff --git a/debian/patches/allocator-Avoid-integer-overflow-when-allocating-sys.patch b/debian/patches/allocator-Avoid-integer-overflow-when-allocating-sys.patch
new file mode 100644
index 0000000..9362a8d
--- /dev/null
+++ b/debian/patches/allocator-Avoid-integer-overflow-when-allocating-sys.patch
@@ -0,0 +1,48 @@
+From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= <sebastian@centricular.com>
+Date: Thu, 26 Sep 2024 22:07:22 +0300
+Subject: allocator: Avoid integer overflow when allocating sysmem
+Origin: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/commit/72af11b248b4cb60d3dfe4e9459eec0d20052c9b
+Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2024-47606
+
+Thanks to Antonio Morales for finding and reporting the issue.
+
+Fixes GHSL-2024-166
+Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3851
+
+Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8044>
+---
+ subprojects/gstreamer/gst/gstallocator.c | 14 ++++++++++++++
+ 1 file changed, 14 insertions(+)
+
+--- a/gst/gstallocator.c
++++ b/gst/gstallocator.c
+@@ -430,8 +430,20 @@ _sysmem_new_block (GstMemoryFlags flags,
+   /* ensure configured alignment */
+   align |= gst_memory_alignment;
+   /* allocate more to compensate for alignment */
++  if (align > G_MAXSIZE || maxsize > G_MAXSIZE - align) {
++    GST_CAT_WARNING (GST_CAT_MEMORY,
++        "Allocating %" G_GSIZE_FORMAT " bytes with alignment %" G_GSIZE_FORMAT
++        "x overflows", maxsize, align);
++    return NULL;
++  }
+   maxsize += align;
+   /* alloc header and data in one block */
++  if (maxsize > G_MAXSIZE - sizeof (GstMemorySystem)) {
++    GST_CAT_WARNING (GST_CAT_MEMORY,
++        "Allocating %" G_GSIZE_FORMAT " bytes with alignment %" G_GSIZE_FORMAT
++        "x overflows", maxsize, align);
++    return NULL;
++  }
+   slice_size = sizeof (GstMemorySystem) + maxsize;
+ 
+   mem = g_slice_alloc (slice_size);
+@@ -481,6 +493,8 @@ _sysmem_copy (GstMemorySystem * mem, gss
+     size = mem->mem.size > offset ? mem->mem.size - offset : 0;
+ 
+   copy = _sysmem_new_block (0, size, mem->mem.align, 0, size);
++  if (!copy)
++    return NULL;
+   GST_CAT_DEBUG (GST_CAT_PERFORMANCE,
+       "memcpy %" G_GSIZE_FORMAT " memory %p -> %p", size, mem, copy);
+   memcpy (copy->data, mem->data + mem->mem.offset + offset, size);
diff --git a/debian/patches/series b/debian/patches/series
index cbeba03..1443081 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
 0001-registrybinary-Update-magic-version-string.patch
+allocator-Avoid-integer-overflow-when-allocating-sys.patch
-- 
GitLab


From 25ff91375e2e229893dc45423ba80ae81063037b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dylan=20A=C3=AFssi?= <devel@lists.apertis.org>
Date: Mon, 6 Jan 2025 08:55:36 +0000
Subject: [PATCH 2/3] Release gstreamer1.0 version 1.22.0-2+deb12u1+apertis1
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Dylan Aïssi <dylan.aissi@collabora.com>
---
 debian/changelog | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 058dfe7..f077df0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+gstreamer1.0 (1.22.0-2+deb12u1+apertis1) apertis; urgency=medium
+
+  * Sync from debian/bookworm-security.
+  * Remaining Apertis specific changes:
+    - Drop dependency on LGPL-3 libdw for better backtraces
+
+ -- Apertis CI <devel@lists.apertis.org>  Mon, 06 Jan 2025 08:55:36 +0000
+
 gstreamer1.0 (1.22.0-2+deb12u1) bookworm-security; urgency=high
 
   * Non-maintainer upload by the Security Team.
-- 
GitLab


From ca12e93ad0fdad4d7dda786688e19979df54e7a5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dylan=20A=C3=AFssi?= <dylan.aissi@collabora.com>
Date: Mon, 6 Jan 2025 09:12:51 +0000
Subject: [PATCH 3/3] Refresh the automatically detected licensing information
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Dylan Aïssi <dylan.aissi@collabora.com>
---
 debian/apertis/copyright | 1 -
 1 file changed, 1 deletion(-)

diff --git a/debian/apertis/copyright b/debian/apertis/copyright
index 5e32515..8941513 100644
--- a/debian/apertis/copyright
+++ b/debian/apertis/copyright
@@ -1134,4 +1134,3 @@ License: LGPL-2+
 Files: tools/tools.h
 Copyright: 2004, 2005, Benjamin Otte <otte@gnome.org>
 License: LGPL-2+
-
-- 
GitLab