blog/libconsole-Correctly-ignore-early-consoles.patch
Dr. Werner Fink 937beaa81b Accepting request 556516 from home:pmladek:branches:Base:System
- hardening of the console list generation (bsc#1071568):
  * libconsole-never-return-empty-list-from-getconsoles.patch
  * libconsole-Really-allow-to-use-dev-console-as-a-fall.patch
  * libconsole-Add-console-into-the-list-only-when-succe.patch
  * libconsole-Correctly-ignore-early-consoles.patch

OBS-URL: https://build.opensuse.org/request/show/556516
OBS-URL: https://build.opensuse.org/package/show/Base:System/blog?expand=0&rev=26
2017-12-12 16:12:12 +00:00

56 lines
1.4 KiB
Diff

From: Petr Mladek <pmladek@suse.com>
Date: Tue, 12 Dec 2017 12:49:39 +0100
Subject: libconsole: Correctly ignore early consoles
Git-commit: 08b7314b53524040a16ce2a7f95a73304c55db30
References: bsc#1071568
Upstream: merged
There might be consoles without tty binding. These do not have
defined major and minor numbers in the /proc/consoles list.
For example, it might look like:
$> cat /proc/consoles
pl11 -W- (E Bp )
ttyAMA0 -W- (EC p a) 204:64
Let's just ignore them.
Signed-off-by: Petr Mladek <pmladek@suse.com>
---
libconsole/console.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/libconsole/console.c b/libconsole/console.c
index 47e95a4b9046..c4396b1f9b5e 100644
--- a/libconsole/console.c
+++ b/libconsole/console.c
@@ -609,6 +609,7 @@ void getconsoles(struct console **cons, int io)
char fbuf[16], dev[64];
char *tty = NULL;
FILE *fc;
+ int items;
if (!cons)
error("error: console pointer empty");
@@ -621,11 +622,16 @@ void getconsoles(struct console **cons, int io)
goto err;
}
- while ((fscanf(fc, "%*s %*s (%[^)]) %[0-9:]", &fbuf[0], &dev[0]) == 2)) {
+ while ((items = fscanf(fc, "%*s %*s (%[^)]) %[0-9:]", &fbuf[0], &dev[0]))
+ != EOF) {
char *tmp;
int flags, n, maj, min;
int ret;
+ /* Ignore consoles without tty binding. */
+ if (items != 2)
+ continue;
+
if (!strchr(fbuf, 'E'))
continue;
--
2.13.6