Skip to content

Commit

Permalink
Fix issue #95
Browse files Browse the repository at this point in the history
Properly terminate command line by 0x0d if length is >=126 and fix
overwriting [0x100].
  • Loading branch information
boeckmann authored and PerditionC committed May 25, 2024
1 parent c85401e commit 68eb708
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,14 @@ int exec(const char *cmd, char *cmdLine, const unsigned segOfEnv)
buf[0] = (unsigned char)(MAX_EXTERNAL_COMMAND_SIZE+1);
memcpy(&buf[1], cmdLine, MAX_EXTERNAL_COMMAND_SIZE);
/* terminate with just carriage return \r */
memcpy(&buf[1] + buf[0], "\xd", 1);
buf[MAX_EXTERNAL_COMMAND_SIZE+1] = '\x0d';
} else {
/* set size of actual command line and copy to buffer */
memcpy(&buf[1], cmdLine, buf[0] = strlen(cmdLine));
/* ensure terminated with \r\0 */
memcpy(&buf[1] + buf[0], "\xd", 2);
buf[0] = (unsigned char)cmdLen;
memcpy(&buf[1], cmdLine, cmdLen);
/* ensure terminated with \r\0, if less then 126 characters
or \r, if exactly 126 characters */
memcpy(&buf[1] + cmdLen, "\x0d", (cmdLen < MAX_EXTERNAL_COMMAND_SIZE) ? 2 : 1);
}

/* fill FCBs */
Expand Down

0 comments on commit 68eb708

Please sign in to comment.