mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Stopped copying arguments to fixed-size buffers
Don't needlessly copy command-line arguments into fixed-size buffers. Previously the program crashed if an overlong pathname was provided on the command line. Also, some systems (such as GNU Hurd) don't define MAXPATHLEN at all.
This commit is contained in:
parent
8fe74a7579
commit
c3b948725e
2 changed files with 4 additions and 4 deletions
|
|
@ -30,9 +30,9 @@
|
||||||
/* Options */
|
/* Options */
|
||||||
struct option_t
|
struct option_t
|
||||||
{
|
{
|
||||||
char tty_device[MAXPATHLEN];
|
const char *tty_device;
|
||||||
bool log;
|
bool log;
|
||||||
char log_filename[_POSIX_ARG_MAX];
|
const char *log_filename;
|
||||||
bool no_autoconnect;
|
bool no_autoconnect;
|
||||||
int output_delay;
|
int output_delay;
|
||||||
struct termios tio;
|
struct termios tio;
|
||||||
|
|
|
||||||
|
|
@ -314,7 +314,7 @@ void parse_options(int argc, char *argv[])
|
||||||
|
|
||||||
case 'l':
|
case 'l':
|
||||||
option.log = true;
|
option.log = true;
|
||||||
strncpy(option.log_filename, optarg, _POSIX_ARG_MAX);
|
option.log_filename = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
|
|
@ -344,7 +344,7 @@ void parse_options(int argc, char *argv[])
|
||||||
|
|
||||||
/* Assume first non-option is the tty device name */
|
/* Assume first non-option is the tty device name */
|
||||||
if (optind < argc)
|
if (optind < argc)
|
||||||
strcpy(option.tty_device, argv[optind++]);
|
option.tty_device = argv[optind++];
|
||||||
|
|
||||||
if (strlen(option.tty_device) == 0)
|
if (strlen(option.tty_device) == 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue