From 5ed8647b9e5df0b0ea32d6d26b3a96479ed05145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20G=C3=A1l?= Date: Thu, 3 Oct 2019 09:26:50 +0200 Subject: [PATCH] Improve example REPL to exit if there is nothing on the stdin (#3193) When reading from the stdin a '\n' character or an empty line/file was expected to end the read. However, in case of an input which is not terminated with a newline a buffer overflow will occur. Test case: ```sh $ echo -n "print('a')" | ./build/bin/jerry ``` JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com --- jerry-main/main-unix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jerry-main/main-unix.c b/jerry-main/main-unix.c index 2020bd0c8..fb111d0b7 100644 --- a/jerry-main/main-unix.c +++ b/jerry-main/main-unix.c @@ -861,7 +861,7 @@ main (int argc, /* Read a line */ while (true) { - if (fread (source_buffer_tail, 1, 1, stdin) != 1 && len == 0) + if (fread (source_buffer_tail, 1, 1, stdin) != 1) { is_done = true; break;