commit:     b7cdb9f1997d5123ad92ac9f17079b7e67e52f29
Author:     Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
AuthorDate: Wed Jan  4 01:08:02 2023 +0000
Commit:     Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
CommitDate: Wed Jan  4 01:08:35 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b7cdb9f1

app-arch/dpkg: replace buf patch with upstream fix in 1.21.15

Signed-off-by: Georgy Yakovlev <gyakovlev <AT> gentoo.org>

 ...{dpkg-1.21.15.ebuild => dpkg-1.21.15-r1.ebuild} |  2 +-
 app-arch/dpkg/files/dpkg-1.21.15-buf-lengh.patch   | 34 ----------------
 .../dpkg/files/dpkg-1.21.15-buf-overflow.patch     | 45 ++++++++++++++++++++++
 3 files changed, 46 insertions(+), 35 deletions(-)

diff --git a/app-arch/dpkg/dpkg-1.21.15.ebuild 
b/app-arch/dpkg/dpkg-1.21.15-r1.ebuild
similarity index 97%
rename from app-arch/dpkg/dpkg-1.21.15.ebuild
rename to app-arch/dpkg/dpkg-1.21.15-r1.ebuild
index 02e4f4a95589..d26e233149be 100644
--- a/app-arch/dpkg/dpkg-1.21.15.ebuild
+++ b/app-arch/dpkg/dpkg-1.21.15-r1.ebuild
@@ -46,7 +46,7 @@ BDEPEND="
 
 PATCHES=(
        "${FILESDIR}"/${PN}-1.18.12-flags.patch
-       "${FILESDIR}"/${PN}-1.21.15-buf-lengh.patch # sent upstream
+       "${FILESDIR}"/${P}-buf-overflow.patch
 )
 
 src_prepare() {

diff --git a/app-arch/dpkg/files/dpkg-1.21.15-buf-lengh.patch 
b/app-arch/dpkg/files/dpkg-1.21.15-buf-lengh.patch
deleted file mode 100644
index 1ab28d1df5a0..000000000000
--- a/app-arch/dpkg/files/dpkg-1.21.15-buf-lengh.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-From 7caf70b6cda200e1bad77c26e46e465a4ad76d71 Mon Sep 17 00:00:00 2001
-From: Georgy Yakovlev <gyakov...@gentoo.org>
-Date: Mon, 2 Jan 2023 21:57:29 -0800
-Subject: [PATCH] dpkg-deb: increase buf lengh in movecontrolfiles
-
-In some cases limit of 200 is too short.
-For example, on gentoo we build in /var/tmp/portage (user configurable)
-
-the buf contents end up exactly 201 characters:
-e.g.: "mv /long/path /another/long/path && rmdir /yet/another/long/path"
-
-so we only catch it in testsuite and dpkg-deb tests fail sometimes.
-
-Signed-off-by: Georgy Yakovlev <gyakov...@gentoo.org>
----
- src/deb/extract.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/deb/extract.c b/src/deb/extract.c
-index a098539..332c664 100644
---- a/src/deb/extract.c
-+++ b/src/deb/extract.c
-@@ -53,7 +53,7 @@
- static void
- movecontrolfiles(const char *dir, const char *thing)
- {
--  char buf[200];
-+  char buf[512];
-   pid_t pid;
- 
-   sprintf(buf, "mv %s/%s/* %s/ && rmdir %s/%s", dir, thing, dir, dir, thing);
--- 
-2.39.0
-

diff --git a/app-arch/dpkg/files/dpkg-1.21.15-buf-overflow.patch 
b/app-arch/dpkg/files/dpkg-1.21.15-buf-overflow.patch
new file mode 100644
index 000000000000..864d57b98a5c
--- /dev/null
+++ b/app-arch/dpkg/files/dpkg-1.21.15-buf-overflow.patch
@@ -0,0 +1,45 @@
+From 5356621172d669d8f62e7e746a6c7a11345aec4e Mon Sep 17 00:00:00 2001
+From: Guillem Jover <guil...@debian.org>
+Date: Tue, 3 Jan 2023 23:29:05 +0100
+Subject: dpkg-deb: Fix buffer overflow on long directory names with old deb
+ formats
+
+The handling for deb 0.x formats that relocates files around once
+extracted was using a buffer with a hardcoded size, not taking into
+account the length of the directory which would overflow it.
+
+Switch to use a dynamically allocated buffer to handle any destination
+directory length.
+
+Reported-by: Georgy Yakovlev <gyakov...@gentoo.org>
+---
+ src/deb/extract.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/src/deb/extract.c b/src/deb/extract.c
+index a09853962..6466fa6f2 100644
+--- a/src/deb/extract.c
++++ b/src/deb/extract.c
+@@ -53,15 +53,16 @@
+ static void
+ movecontrolfiles(const char *dir, const char *thing)
+ {
+-  char buf[200];
++  char *cmd;
+   pid_t pid;
+ 
+-  sprintf(buf, "mv %s/%s/* %s/ && rmdir %s/%s", dir, thing, dir, dir, thing);
++  cmd = str_fmt("mv %s/%s/* %s/ && rmdir %s/%s", dir, thing, dir, dir, thing);
+   pid = subproc_fork();
+   if (pid == 0) {
+-    command_shell(buf, _("shell command to move files"));
++    command_shell(cmd, _("shell command to move files"));
+   }
+   subproc_reap(pid, _("shell command to move files"), 0);
++  free(cmd);
+ }
+ 
+ static void DPKG_ATTR_NORET
+-- 
+cgit v1.2.3
+

Reply via email to