Skip to content

Commit

Permalink
fix ub in main arg parse (#291)
Browse files Browse the repository at this point in the history
Modifying value after removing its const qualifier is UB.
Let `arg` be mutable, it was designed to be modified and we do not need a const qualifier anyway.
  • Loading branch information
scuzqy authored Dec 27, 2024
1 parent 7b7b0e9 commit 91472da
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/quicreach.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ struct ReachResults {
}
} Results;

void AddHostName(const char* arg) {
void AddHostName(char* arg) {
// Parse hostname(s), treating '*' as all top-level domains.
if (!strcmp(arg, "*")) {
for (const auto& Domain : TopDomains) {
Config.HostNames.push_back(Domain);
}
} else {
char* HostName = const_cast<char*>(arg);
char* HostName = arg;
do {
char* End = strchr(HostName, ',');
if (End) *End = '\0';
Expand Down

0 comments on commit 91472da

Please sign in to comment.