[Bug Fix] Add Validation to #find, #set, and #show args (#3598)

# Notes
- We were not validating `sep->arg[i]` so we could possibly be pushing a `nullptr` in.
This commit is contained in:
Alex King 2023-09-17 22:20:27 -04:00 committed by GitHub
parent df1d740ae6
commit 26e72c6857
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 3 deletions

View File

@ -72,8 +72,10 @@ void command_find(Client *c, const Seperator *sep)
// skip the first arg // skip the first arg
for (auto i = 1; i <= arguments; i++) { for (auto i = 1; i <= arguments; i++) {
if (sep->arg[i]) {
args.emplace_back(sep->arg[i]); args.emplace_back(sep->arg[i]);
} }
}
// build the rewrite string // build the rewrite string
std::string rewrite = fmt::format("#find {} {}", cmd.cmd, Strings::Join(args, " ")); std::string rewrite = fmt::format("#find {} {}", cmd.cmd, Strings::Join(args, " "));

View File

@ -136,8 +136,10 @@ void command_set(Client *c, const Seperator *sep)
// skip the first arg // skip the first arg
for (auto i = 1; i <= arguments; i++) { for (auto i = 1; i <= arguments; i++) {
if (sep->arg[i]) {
args.emplace_back(sep->arg[i]); args.emplace_back(sep->arg[i]);
} }
}
// build the rewrite string // build the rewrite string
const std::string& rewrite = fmt::format("#set {} {}", cmd.cmd, Strings::Join(args, " ")); const std::string& rewrite = fmt::format("#set {} {}", cmd.cmd, Strings::Join(args, " "));

View File

@ -115,8 +115,10 @@ void command_show(Client *c, const Seperator *sep)
// skip the first arg // skip the first arg
for (auto i = 1; i <= arguments; i++) { for (auto i = 1; i <= arguments; i++) {
if (sep->arg[i]) {
args.emplace_back(sep->arg[i]); args.emplace_back(sep->arg[i]);
} }
}
// build the rewrite string // build the rewrite string
const std::string& rewrite = fmt::format("#show {} {}", cmd.cmd, Strings::Join(args, " ")); const std::string& rewrite = fmt::format("#show {} {}", cmd.cmd, Strings::Join(args, " "));