From c95279917023ed6d35549c67b4cf6fc7c807e4ae3f68a8bc5fea1965b811ff4f Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Tue, 31 Oct 2023 16:34:51 +0000 Subject: [PATCH] Accepting request 1121456 from home:Guillaume_G:branches:Base:System - Add patch: * setterm-resize-uninit-flags.patch OBS-URL: https://build.opensuse.org/request/show/1121456 OBS-URL: https://build.opensuse.org/package/show/Base:System/util-linux?expand=0&rev=533 --- setterm-resize-uninit-flags.patch | 38 +++++++++++++++++++++++++++++++ util-linux.changes | 6 +++++ util-linux.spec | 2 ++ 3 files changed, 46 insertions(+) create mode 100644 setterm-resize-uninit-flags.patch diff --git a/setterm-resize-uninit-flags.patch b/setterm-resize-uninit-flags.patch new file mode 100644 index 0000000..db7ba8d --- /dev/null +++ b/setterm-resize-uninit-flags.patch @@ -0,0 +1,38 @@ +From: Chris Hofstaedtler +Date: Mon, 30 Oct 2023 22:59:33 +0100 +Subject: setterm: avoid restoring flags from uninitialized memory + +Depending on the used compiler and flags, previously either F_SETFL was called +with 0 or with a random value. Never with the intended previous flags. + +Signed-off-by: Chris Hofstaedtler +--- + term-utils/setterm.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/term-utils/setterm.c b/term-utils/setterm.c +index 22afc76..a477d5d 100644 +--- a/term-utils/setterm.c ++++ b/term-utils/setterm.c +@@ -846,7 +846,11 @@ static void tty_raw(struct termios *saved_attributes, int *saved_fl) + { + struct termios tattr; + +- fcntl(STDIN_FILENO, F_GETFL, saved_fl); ++ *saved_fl = fcntl(STDIN_FILENO, F_GETFL); ++ if (*saved_fl == -1) { ++ err(EXIT_FAILURE, _("fcntl failed: %s"), ++ strerror(errno)); ++ } + tcgetattr(STDIN_FILENO, saved_attributes); + fcntl(STDIN_FILENO, F_SETFL, O_NONBLOCK); + memcpy(&tattr, saved_attributes, sizeof(struct termios)); +@@ -898,7 +902,7 @@ static int resizetty(void) + ssize_t rc; + struct winsize ws; + struct termios saved_attributes; +- int saved_fl; ++ int saved_fl = 0; + + if (!isatty(STDIN_FILENO)) + errx(EXIT_FAILURE, _("stdin does not refer to a terminal")); diff --git a/util-linux.changes b/util-linux.changes index fcb2ca8..a4c23fc 100644 --- a/util-linux.changes +++ b/util-linux.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Tue Oct 31 13:20:38 UTC 2023 - Guillaume GARDET + +- Add patch: + * setterm-resize-uninit-flags.patch + ------------------------------------------------------------------- Fri Sep 8 20:13:24 UTC 2023 - Antonio Teixeira diff --git a/util-linux.spec b/util-linux.spec index a2de2d2..370f1a4 100644 --- a/util-linux.spec +++ b/util-linux.spec @@ -116,6 +116,8 @@ Patch4: 0001-Revert-libblkid-try-LUKS2-first-when-probing.patch Patch5: util-linux-fix-tests-with-64k-pagesize.patch # https://github.com/util-linux/util-linux/pull/2100 Patch6: use-logind-not-utmp.patch +# https://salsa.debian.org/debian/util-linux/-/raw/master/debian/patches/debian/setterm-resize-uninit-flags.patch?inline=false +Patch7: setterm-resize-uninit-flags.patch BuildRequires: audit-devel BuildRequires: bc