Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing several buffer overflow in parse_arguments in n64split #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions n64split.c
Original file line number Diff line number Diff line change
Expand Up @@ -2211,7 +2211,10 @@ static void parse_arguments(int argc, char *argv[], arg_config *config)
if (++i >= argc) {
print_usage();
}
strcpy(config->config_file, argv[i]);
// Unsecure
// strcpy(config->config_file, argv[i]);
// Secure version below
strncpy(config->config_file, argv[i], FILENAME_MAX);
break;
case 'k':
config->keep_going = true;
Expand All @@ -2223,7 +2226,10 @@ static void parse_arguments(int argc, char *argv[], arg_config *config)
if (++i >= argc) {
print_usage();
}
strcpy(config->output_dir, argv[i]);
//Unsecure (buffer overflow)
// strcpy(config->output_dir, argv[i]);
//Secure version below without buffer overflow
strncpy(config->output_dir, argv[i], FILENAME_MAX);
break;
case 'r':
config->raw_texture = true;
Expand All @@ -2250,7 +2256,9 @@ static void parse_arguments(int argc, char *argv[], arg_config *config)
}
} else {
if (file_count == 0) {
strcpy(config->input_file, argv[i]);
// strcpy(config->input_file, argv[i]);
//Secure version without buffer overflow
strncpy(config->input_file, argv[i], FILENAME_MAX);
} else {
// too many
print_usage();
Expand Down