[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@gmail.com>
This commit is contained in:
CodeforEvolution 2019-10-21 10:27:38 -05:00 committed by Jérôme Duval
parent 0156f4ffef
commit 89fc6d6aa2
1 changed files with 5 additions and 2 deletions

View File

@ -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) {