File libconsole-never-return-empty-list-from-getconsoles.patch of Package blog
From: Petr Mladek <pmladek@suse.com>
Date: Mon, 11 Dec 2017 16:32:11 +0100
Subject: libconsole: never return empty list from getconsoles()
Git-commit: d7fe84cd6198c4acc00a59d7c403fe6bdc3f509a
References: bsc#1071568
Upstream: merged
getconsoles() users expect that they get a non-empty list of consoles.
Otherwise, they might access an invalid memory.
There is an attempt to create fallback to /dev/console but it is
used (assigned to *cons) only when the corresponding consalloc()
passes. Otherwise, we should printk an error and exit.
Signed-off-by: Petr Mladek <pmladek@suse.com>
---
libconsole/console.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/libconsole/console.c b/libconsole/console.c
index 2c6bbac8989f..2f6e0b1d56d9 100644
--- a/libconsole/console.c
+++ b/libconsole/console.c
@@ -662,8 +662,10 @@ err:
if (!tty)
error("can not allocate string");
- if (consalloc(&c, tty, CON_CONSDEV, makedev(TTYAUX_MAJOR, 1), io))
- *cons = c;
+ if (!consalloc(&c, tty, CON_CONSDEV, makedev(TTYAUX_MAJOR, 1), io))
+ error("/dev/console is not a valid fallback\n");
+
+ *cons = c;
}
/*
--
2.13.6