summaryrefslogtreecommitdiffstats
path: root/lib/readline_simple.c
diff options
context:
space:
mode:
authorGaël PORTAY <gael.portay@savoirfairelinux.com>2017-08-07 18:10:41 -0400
committerLucas Stach <l.stach@pengutronix.de>2017-08-15 15:39:11 +0200
commiteb06f54b3a2ebbdf09b2d53d787f8d9ed35adff5 (patch)
tree9d6c2748f49f2b86e70d4a733653285a718fd4a0 /lib/readline_simple.c
parent901c28ab600e9f3dd02c3dce1e052f6cf94a2aaa (diff)
downloadbarebox-eb06f54b3a2ebbdf09b2d53d787f8d9ed35adff5.tar.gz
barebox-eb06f54b3a2ebbdf09b2d53d787f8d9ed35adff5.tar.xz
readline_simple: return -1 if getc fails
The getc function may return an errno code if an error happens. This patch prevents readline from printing a non printable character and from looping to infinity and beyong. Signed-off-by: Gaël PORTAY <gael.portay@savoirfairelinux.com> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Diffstat (limited to 'lib/readline_simple.c')
-rw-r--r--lib/readline_simple.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/readline_simple.c b/lib/readline_simple.c
index c4d3d240e5..1283c96021 100644
--- a/lib/readline_simple.c
+++ b/lib/readline_simple.c
@@ -58,6 +58,8 @@ int readline (const char *prompt, char *line, int len)
for (;;) {
c = getchar();
+ if (c < 0)
+ return (-1);
/*
* Special character handling