summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author7c6f434c <7c6f434c@mail.ru>2025-02-26 07:11:30 +0000
committerGitHub <noreply@github.com>2025-02-26 07:11:30 +0000
commit2e8b0d29389e127565637d33ea2f4612deef6aee (patch)
treeaeb343993d18264dfe2f68dfb134bd6fb17f9d73
parentkdePackages.kwin: 6.3.2 -> 6.3.2.1 (#385181) (diff)
parentscreen: fix the use of strncpy when using -X (diff)
downloadnixpkgs-2e8b0d29389e127565637d33ea2f4612deef6aee.tar.gz
screen: fix the use of strncpy when using -X (#384846)
-rw-r--r--pkgs/tools/misc/screen/buffer-overflow-SendCmdMessage.patch13
-rw-r--r--pkgs/tools/misc/screen/default.nix7
2 files changed, 20 insertions, 0 deletions
diff --git a/pkgs/tools/misc/screen/buffer-overflow-SendCmdMessage.patch b/pkgs/tools/misc/screen/buffer-overflow-SendCmdMessage.patch
new file mode 100644
index 000000000000..c9a13d800017
--- /dev/null
+++ b/pkgs/tools/misc/screen/buffer-overflow-SendCmdMessage.patch
@@ -0,0 +1,13 @@
+--- a/attacher.c 2025-02-24 20:15:31.701820351 +0100
++++ b/attacher.c 2025-02-24 20:17:05.893826559 +0100
+@@ -461,8 +461,8 @@
+ size_t len;
+ len = strlen(*av) + 1;
+ if (p + len >= m.m.command.cmd + ARRAY_SIZE(m.m.command.cmd) - 1)
+- break;
++ Panic(0, "Total length of the command to send too large.\n");
+- strncpy(p, *av, MAXPATHLEN);
++ memcpy(p, *av, len);
+ p += len;
+ }
+ *p = 0;
diff --git a/pkgs/tools/misc/screen/default.nix b/pkgs/tools/misc/screen/default.nix
index 3c50af1fe6bf..7d32d467bfc1 100644
--- a/pkgs/tools/misc/screen/default.nix
+++ b/pkgs/tools/misc/screen/default.nix
@@ -26,6 +26,13 @@ stdenv.mkDerivation rec {
# We need _GNU_SOURCE so that mallocmock_reset() is defined: https://savannah.gnu.org/bugs/?66416
NIX_CFLAGS_COMPILE = lib.optionalString (stdenv.cc.isGNU) "-D_GNU_SOURCE=1 -Wno-int-conversion -Wno-incompatible-pointer-types";
+ patches = [
+ # GNU Screen 5.0 uses strncpy incorrectly in SendCmdMessage
+ # This causes issues detected when using -D_FORTIFY_SOURCE=3
+ # e.g. https://savannah.gnu.org/bugs/index.php?66215
+ ./buffer-overflow-SendCmdMessage.patch
+ ];
+
nativeBuildInputs = [
autoreconfHook
];