|
27 | 27 |
|
28 | 28 | #include "../include/SU2_SOL.hpp" |
29 | 29 |
|
| 30 | +#include <cstring> |
| 31 | + |
30 | 32 | using namespace std; |
31 | 33 |
|
32 | 34 | int main(int argc, char* argv[]) { |
@@ -56,7 +58,11 @@ int main(int argc, char* argv[]) { |
56 | 58 | file is specified, default.cfg is used) ---*/ |
57 | 59 |
|
58 | 60 | if (argc == 2 || argc == 3) { |
59 | | - strcpy(config_file_name, argv[1]); |
| 61 | + if (strlen(argv[1]) >= MAX_STRING_SIZE) { |
| 62 | + SU2_MPI::Error("Config file path too long (exceeds MAX_STRING_SIZE).", CURRENT_FUNCTION); |
| 63 | + } |
| 64 | + strncpy(config_file_name, argv[1], MAX_STRING_SIZE - 1); |
| 65 | + config_file_name[MAX_STRING_SIZE - 1] = '\0'; |
60 | 66 | } else { |
61 | 67 | strcpy(config_file_name, "default.cfg"); |
62 | 68 | } |
@@ -98,7 +104,12 @@ int main(int argc, char* argv[]) { |
98 | 104 | read and stored. ---*/ |
99 | 105 |
|
100 | 106 | if (driver_config->GetnConfigFiles() > 0) { |
101 | | - strcpy(zone_file_name, driver_config->GetConfigFilename(iZone).c_str()); |
| 107 | + const auto& zone_filename = driver_config->GetConfigFilename(iZone); |
| 108 | + if (zone_filename.size() >= MAX_STRING_SIZE) { |
| 109 | + SU2_MPI::Error("Zone config file path too long (exceeds MAX_STRING_SIZE).", CURRENT_FUNCTION); |
| 110 | + } |
| 111 | + strncpy(zone_file_name, zone_filename.c_str(), MAX_STRING_SIZE - 1); |
| 112 | + zone_file_name[MAX_STRING_SIZE - 1] = '\0'; |
102 | 113 | config_container[iZone] = new CConfig(driver_config, zone_file_name, SU2_COMPONENT::SU2_SOL, iZone, nZone, true); |
103 | 114 | } else { |
104 | 115 | config_container[iZone] = |
|
0 commit comments