Procházet zdrojové kódy

Fix out-of-bounds array access for option characters >= 128 (#3151)

Bug found by fuzzing.
josh11b před 2 roky
rodič
revize
f790a27ace

+ 2 - 1
common/command_line.cpp

@@ -985,7 +985,8 @@ auto Parser::ParseShortOptionSeq(llvm::StringRef unparsed_arg) -> bool {
   }
 
   for (unsigned char c : unparsed_arg) {
-    auto* arg_entry = short_option_table_[c];
+    auto* arg_entry =
+        (c < short_option_table_.size()) ? short_option_table_[c] : nullptr;
     if (!arg_entry) {
       errors_ << "ERROR: Unknown short option '" << c << "'\n";
       return false;

binární
toolchain/driver/fuzzer_corpus/d6e1cfb07890f99e8e5142c9868cf0a7d07b97ab