aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2018-10-02 06:43:38 +0200
committerAlexander Graf <agraf@suse.de>2018-10-16 16:39:19 +0200
commit60d798765666a2e967ef818a2a0df8ef1d0ab789 (patch)
tree8391630bcac3938dea1c7c850d6c2c38f97f87c5 /lib
parenteee6530ed1a8174d0f60e4c3c86bea3274c95951 (diff)
downloadu-boot-60d798765666a2e967ef818a2a0df8ef1d0ab789.zip
u-boot-60d798765666a2e967ef818a2a0df8ef1d0ab789.tar.gz
u-boot-60d798765666a2e967ef818a2a0df8ef1d0ab789.tar.bz2
efi_loader: error handling in read_console()
getc() might return an error code. Avoid an incorrect converison to Unicode. This addresses CoverityScan CID 184087. Reported-by: Tom Rini <trini@konsulko.com> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/charset.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/charset.c b/lib/charset.c
index 0cede9b..10557b9 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)