summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2021-03-22 07:55:26 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2021-03-22 10:18:42 +0100
commitb09a15ce42f344bd4f4f67ab509b774274920e2c (patch)
tree3325b9afad25551274a2f9b589ad25aec61be1f8 /commands
parentca2cc1e48bbcbc9b3d20d20d859e6d2dc351ec36 (diff)
downloadbarebox-b09a15ce42f344bd4f4f67ab509b774274920e2c.tar.gz
barebox-b09a15ce42f344bd4f4f67ab509b774274920e2c.tar.xz
common: readline: fix possible buffer overflows
Entering very long lines can crash the readline prompt due to missing NUL terminator. Make sure we don't exceed CONFIG_CBSIZE to avoid this. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r--commands/readline.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/commands/readline.c b/commands/readline.c
index 7933a58c08..57c8fbd7bc 100644
--- a/commands/readline.c
+++ b/commands/readline.c
@@ -19,7 +19,7 @@ static int do_readline(int argc, char *argv[])
command_slice_release();
- if (readline(argv[1], buf, CONFIG_CBSIZE) < 0) {
+ if (readline(argv[1], buf, CONFIG_CBSIZE - 1) < 0) {
command_slice_acquire();
free(buf);
return COMMAND_ERROR;