summaryrefslogtreecommitdiff
path: root/system/lvm2/fix-stdio-usage.patch
diff options
context:
space:
mode:
Diffstat (limited to 'system/lvm2/fix-stdio-usage.patch')
-rw-r--r--system/lvm2/fix-stdio-usage.patch35
1 files changed, 30 insertions, 5 deletions
diff --git a/system/lvm2/fix-stdio-usage.patch b/system/lvm2/fix-stdio-usage.patch
index 69832c004..2b3f0a91f 100644
--- a/system/lvm2/fix-stdio-usage.patch
+++ b/system/lvm2/fix-stdio-usage.patch
@@ -1,6 +1,28 @@
---- LVM2.2.03.08/tools/lvmcmdline.c 2020-02-11 03:59:27.000000000 -0600
-+++ LVM2.2.03.08/tools/lvmcmdline.c 2020-03-22 16:17:35.470100377 -0500
-@@ -3233,7 +3233,7 @@ static int _check_standard_fds(void)
+From 4cf08811e112100a2b10c60047f3c537ad21d674 Mon Sep 17 00:00:00 2001
+From: David Seifert <soap@gentoo.org>
+Date: Sat, 28 Jan 2023 14:22:42 +0100
+Subject: [PATCH] Use `freopen()` on {stdin,stdout,stderr}
+
+* ISO C does not guarantee that the standard streams are modifiable
+ lvalues. Glibc even calls out this behaviour as non-portable:
+ https://www.gnu.org/software/libc/manual/html_node/Standard-Streams.html
+--- a/lib/log/log.c
++++ b/lib/log/log.c
+@@ -208,7 +208,11 @@ int reopen_standard_stream(FILE **stream, const char *mode)
+
+ _check_and_replace_standard_log_streams(old_stream, new_stream);
+
++#ifdef __GLIBC__
+ *stream = new_stream;
++#else
++ freopen(NULL, mode, *stream);
++#endif
+ return 1;
+ }
+
+--- a/tools/lvmcmdline.c
++++ b/tools/lvmcmdline.c
+@@ -3422,7 +3422,7 @@ static int _check_standard_fds(void)
int err = is_valid_fd(STDERR_FILENO);
if (!is_valid_fd(STDIN_FILENO) &&
@@ -9,7 +31,7 @@
if (err)
perror("stdin stream open");
else
-@@ -3243,7 +3243,7 @@ static int _check_standard_fds(void)
+@@ -3432,7 +3432,7 @@ static int _check_standard_fds(void)
}
if (!is_valid_fd(STDOUT_FILENO) &&
@@ -18,7 +40,7 @@
if (err)
perror("stdout stream open");
/* else no stdout */
-@@ -3251,7 +3251,7 @@ static int _check_standard_fds(void)
+@@ -3440,7 +3440,7 @@ static int _check_standard_fds(void)
}
if (!is_valid_fd(STDERR_FILENO) &&
@@ -27,3 +49,6 @@
printf("stderr stream open: %s\n",
strerror(errno));
return 0;
+--
+2.39.2
+