hrev53579 adds 1 changeset to branch 'master'
old head: 0156f4ffef441d401c2ed6af86e0ae07e2cd4cd7
new head: 89fc6d6aa211d224ea29dfa586d0e5e64a25eca3
overview:
https://git.haiku-os.org/haiku/log/?qt=range&q=89fc6d6aa211+%5E0156f4ffef44
----------------------------------------------------------------------------
89fc6d6aa211: [hey] - Fix overflow issue found by LGTM
LGTM issue: "gets does not guard against buffer overflow"
Change-Id: I502428f167865ac81301aa72d20c91b4480fb3dc
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1926
Reviewed-by: Adrien Destugues <pulkomandy@xxxxxxxxx>
[ CodeforEvolution <secundaja@xxxxxxxxx> ]
----------------------------------------------------------------------------
Revision: hrev53579
Commit: 89fc6d6aa211d224ea29dfa586d0e5e64a25eca3
URL: https://git.haiku-os.org/haiku/commit/?id=89fc6d6aa211
Author: CodeforEvolution <secundaja@xxxxxxxxx>
Date: Mon Oct 21 15:27:38 2019 UTC
Committer: Jérôme Duval <jerome.duval@xxxxxxxxx>
Commit-Date: Thu Nov 14 16:57:06 2019 UTC
----------------------------------------------------------------------------
1 file changed, 5 insertions(+), 2 deletions(-)
src/bin/hey.cpp | 7 +++++--
----------------------------------------------------------------------------
diff --git a/src/bin/hey.cpp b/src/bin/hey.cpp
index d736808a19..9c3d1b0c3a 100644
--- a/src/bin/hey.cpp
+++ b/src/bin/hey.cpp
@@ -126,6 +126,9 @@ bool is_valid_char(uint8 c);
const char VERSION[] = "v1.2.8";
+#define MAX_INPUT_SIZE 1024
+ // Maximum amount of input data that "hey" can process at a time
+
#define DEBUG_HEY 0 // 1: prints the script message to be sent to
the target application, 0: prints only the reply
@@ -338,10 +341,10 @@ HeyInterpreterThreadHook(void* arg)
if (environment.HasMessenger("Target"))
environment.FindMessenger("Target", &target);
- char command[1024];
+ char command[MAX_INPUT_SIZE];
status_t err;
BMessage reply;
- while (gets(command)) {
+ while (fgets(command, sizeof(command), stdin)) {
reply.MakeEmpty();
err = Hey(&target, command, &reply);
if (!err) {