[U-Boot] [PATCH 1/1] efi_loader: error handling in read_console()
Heinrich Schuchardt
xypron.glpk at gmx.de
Tue Oct 2 04:43:38 UTC 2018
getc() might return an error code. Avoid an incorrect converison to
Unicode.
This addresses CoverityScan CID 184087.
Reported-by: Tom Rini <trini at konsulko.com>
Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
lib/charset.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/lib/charset.c b/lib/charset.c
index 0cede9b60b..10557b9e75 100644
--- a/lib/charset.c
+++ b/lib/charset.c
@@ -97,12 +97,17 @@ static u8 read_string(void *data)
/**
* read_console() - read byte from console
*
- * @src - not used, needed to match interface
- * Return: - byte read
+ * @data - not used, needed to match interface
+ * Return: - byte read or 0 on error
*/
static u8 read_console(void *data)
{
- return getc();
+ int ch;
+
+ ch = getc();
+ if (ch < 0)
+ ch = 0;
+ return ch;
}
int console_read_unicode(s32 *code)
--
2.19.0
More information about the U-Boot
mailing list